Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-04-15 23:55:20
Exec Total Coverage
Lines: 1788 4300 41.6%
Functions: 131 350 37.4%
Branches: 958 2734 35.0%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 // to prevent <map> from generating errors
13 #define __GTHREAD_HIDE_WIN32API 1
14
15 #include "precompiled.h" //always first
16 #include "zc_sys.h"
17
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <math.h>
22 #include <map>
23 #include <filesystem>
24 #include <ctype.h>
25 #include <sstream>
26 #include "base/zc_alleg.h"
27 #include "gamedata.h"
28 #include "zc_init.h"
29 #include "init.h"
30 #include "replay.h"
31 #include "cheats.h"
32 #include "render.h"
33 #include "base/zc_math.h"
34 #include "base/zapp.h"
35 #include "dialog/cheatkeys.h"
36
37 #ifdef ALLEGRO_DOS
38 #include <unistd.h>
39 #endif
40
41 #include "metadata/metadata.h"
42 #include "zelda.h"
43 #include "tiles.h"
44 #include "base/colors.h"
45 #include "pal.h"
46 #include "base/zsys.h"
47 #include "qst.h"
48 #include "zc_sys.h"
49 #include "play_midi.h"
50 #include "debug.h"
51 #include "jwin_a5.h"
52 #include "base/jwinfsel.h"
53 #include "base/gui.h"
54 #include "midi.h"
55 #include "subscr.h"
56 #include "maps.h"
57 #include "sprite.h"
58 #include "guys.h"
59 #include "hero.h"
60 #include "title.h"
61 #include "particles.h"
62 #include "zconsole.h"
63 #include "ffscript.h"
64 #include "dialog/info.h"
65 #include "dialog/alert.h"
66 #include "combos.h"
67 #include <fmt/format.h>
68
69 #ifdef __EMSCRIPTEN__
70 #include "base/emscripten_utils.h"
71 #endif
72
73 extern FFScript FFCore;
74 extern bool Playing;
75 int32_t sfx_voice[WAV_COUNT];
76 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
77 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
78
79 extern byte monochrome_console;
80
81 extern HeroClass Hero;
82 extern FFScript FFCore;
83 extern ZModule zcm;
84 extern zcmodule moduledata;
85 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
86 extern particle_list particles;
87 extern int32_t loadlast;
88 extern word passive_subscreen_doscript;
89 extern bool passive_subscreen_waitdraw;
90 extern char *sfx_string[WAV_COUNT];
91 byte use_dwm_flush;
92 byte use_save_indicator;
93 byte midi_patch_fix;
94 bool midi_paused=false;
95 int32_t paused_midi_pos = 0;
96 byte midi_suspended = 0;
97 byte callback_switchin = 0;
98 byte zc_192b163_warp_compatibility;
99 char modulepath[2048];
100 bool epilepsyFlashReduction;
101 signed char pause_in_background_menu_init = 0;
102 byte pause_in_background = 0;
103 bool is_sys_pal = false;
104 static bool load_control_called_this_frame;
105 extern PALETTE* hw_palette;
106 extern bool update_hw_pal;
107 extern const char* dmaplist(int32_t index, int32_t* list_size);
108 int32_t getnumber(const char *prompt,int32_t initialval);
109
110 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
111 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
112 //extern byte refresh_select_screen;
113 //extern movingblock mblock2; //mblock[4]?
114 //extern int32_t db;
115
116 static const char *ZC_str = "Zelda Classic";
117 extern char save_file_name[1024];
118 #ifdef ALLEGRO_DOS
119 const char *qst_dir_name = "dos_qst_dir";
120 #elif defined(ALLEGRO_WINDOWS)
121 const char *qst_dir_name = "win_qst_dir";
122 static const char *qst_module_name = "current_module";
123 #elif defined(ALLEGRO_LINUX)
124 const char *qst_dir_name = "linux_qst_dir";
125 static const char *qst_module_name = "current_module";
126 #elif defined(__APPLE__)
127 const char *qst_dir_name = "osx_qst_dir";
128 static const char *qst_module_name = "current_module";
129 #endif
130 #ifdef ALLEGRO_LINUX
131 static const char *samplepath = "samplesoundset/patches.dat";
132 #endif
133 char qst_files_path[2048];
134
135 #ifdef _MSC_VER
136 #define getcwd _getcwd
137 #endif
138
139 bool rF11();
140 bool rI();
141 bool rQ();
142 bool zc_key_pressed();
143
144 #ifdef _WIN32
145
146 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
147 extern "C"
148 {
149 typedef HRESULT(WINAPI *t_DwmFlush)();
150 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
151 }
152
153 void do_DwmFlush()
154 {
155 static HMODULE shell = LoadLibrary("dwmapi.dll");
156
157 if(!shell)
158 return;
159
160 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
161 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
162
163 BOOL enabled;
164 isEnabled(&enabled);
165
166 if(isEnabled)
167 flush();
168 }
169
170 #endif // _WIN32
171
172 82451 bool flash_reduction_enabled(bool check_qr)
173 {
174
4/4
✓ Branch 0 taken 80230 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 79774 times.
✓ Branch 3 taken 81995 times.
82451 return (check_qr && get_bit(quest_rules, qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
175 }
176
177 // Dialogue largening
178 void large_dialog(DIALOG *d)
179 {
180 large_dialog(d, 1.5);
181 }
182
183 void large_dialog(DIALOG *d, float RESIZE_AMT)
184 {
185 if(!d[0].d1)
186 {
187 d[0].d1 = 1;
188 int32_t oldwidth = d[0].w;
189 int32_t oldheight = d[0].h;
190 int32_t oldx = d[0].x;
191 int32_t oldy = d[0].y;
192 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
193 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
194 d[0].w = int32_t(d[0].w*RESIZE_AMT);
195 d[0].h = int32_t(d[0].h*RESIZE_AMT);
196
197 for(int32_t i=1; d[i].proc !=NULL; i++)
198 {
199 // Place elements horizontally
200 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
201 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
202
203 if(d[i].proc != d_stringloader)
204 {
205 if(d[i].proc==d_bitmap_proc)
206 {
207 d[i].w *= 2;
208 }
209 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
210 }
211
212 // Place elements vertically
213 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
214 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
215
216 // Vertically resize elements
217 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
218 {
219 d[i].h = int32_t((double)d[i].h*1.5);
220 }
221 else if(d[i].proc == jwin_droplist_proc)
222 {
223 d[i].y += int32_t((double)d[i].h*0.25);
224 d[i].h = int32_t((double)d[i].h*1.25);
225 }
226 else if(d[i].proc==d_bitmap_proc)
227 {
228 d[i].h *= 2;
229 }
230 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
231
232 // Fix frames
233 if(d[i].proc == jwin_frame_proc)
234 {
235 d[i].x++;
236 d[i].y++;
237 d[i].w-=4;
238 d[i].h-=4;
239 }
240 }
241 }
242
243 for(int32_t i=1; d[i].proc!=NULL; i++)
244 {
245 if(d[i].proc==jwin_slider_proc)
246 continue;
247
248 // Bigger font
249 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
250
251 if(!d[i].dp2 && bigfontproc)
252 {
253 d[i].dp2 = get_zc_font(font_lfont_l);
254 }
255 else if(!bigfontproc)
256 {
257 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
258 }
259
260 // Make checkboxes work
261 if(d[i].proc == jwin_check_proc)
262 d[i].proc = jwin_checkfont_proc;
263 else if(d[i].proc == jwin_radio_proc)
264 d[i].proc = jwin_radiofont_proc;
265 }
266
267 jwin_center_dialog(d);
268 }
269
270
271 /**********************************/
272 /******** System functions ********/
273 /**********************************/
274
275 static char cfg_sect[] = "zeldadx"; //We need to rename this.
276 static char ctrl_sect[] = "Controls";
277 static char sfx_sect[] = "Volume";
278
279 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
280 {
281 return D_O_K;
282 }
283
284 bool is_reserved_key(int c)
285 {
286 switch(c)
287 {
288 case KEY_ESC:
289 return true;
290 }
291 return false;
292 }
293 bool is_reserved_keycombo(int c, int modflag)
294 {
295 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
296 return true;
297 return false;
298 }
299 bool checkcheat(Cheat cheat)
300 {
301 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
302 return true; //Main key pressed
303 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
304 return true; //Alt key pressed
305 return false;
306 }
307 31 void load_default_cheatkeys()
308 {
309 31 memset(cheatkeys, 0, sizeof(cheatkeys));
310 31 cheatkeys[Cheat::Life][0] = KEY_H;
311 31 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
312 31 cheatkeys[Cheat::Magic][0] = KEY_M;
313 31 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
314 31 cheatkeys[Cheat::Rupies][0] = KEY_R;
315 31 cheatkeys[Cheat::Bombs][0] = KEY_B;
316 31 cheatkeys[Cheat::Arrows][0] = KEY_A;
317 31 cheatkeys[Cheat::Clock][0] = KEY_I;
318 31 cheatkeys[Cheat::Walls][0] = KEY_F11;
319 31 cheatkeys[Cheat::Fast][0] = KEY_Q;
320 31 cheatkeys[Cheat::Light][0] = KEY_L;
321 31 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
322 31 cheatkeys[Cheat::Kill][0] = KEY_K;
323 31 cheatkeys[Cheat::GoTo][0] = KEY_G;
324 31 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
325 31 cheatkeys[Cheat::ShowL0][0] = KEY_0;
326 31 cheatkeys[Cheat::ShowL1][0] = KEY_1;
327 31 cheatkeys[Cheat::ShowL2][0] = KEY_2;
328 31 cheatkeys[Cheat::ShowL3][0] = KEY_3;
329 31 cheatkeys[Cheat::ShowL4][0] = KEY_4;
330 31 cheatkeys[Cheat::ShowL5][0] = KEY_5;
331 31 cheatkeys[Cheat::ShowL6][0] = KEY_6;
332 31 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
333 31 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
334 31 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
335 31 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
336 31 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
337 31 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
338 31 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
339 31 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
340 31 }
341 31 void load_game_configs()
342 {
343 31 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
344 31 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
345 31 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
346 31 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
347 31 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
348 31 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
349 31 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
350 31 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
351 31 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
352 31 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
353 31 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
354 31 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
355 31 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
356 31 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
357 31 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
358
359 //cheat modifier keya
360 31 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
361 31 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
362 31 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
363 31 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
364
365 //cheat keys
366 31 load_default_cheatkeys();
367 char buf[256];
368
2/2
✓ Branch 0 taken 1085 times.
✓ Branch 1 taken 31 times.
1116 for(size_t q = 1; q < Cheat::Last; ++q)
369 {
370
1/2
✓ Branch 0 taken 1085 times.
✗ Branch 1 not taken.
1085 if(!bindable_cheat((Cheat)q)) continue;
371 1085 std::string cheatname = cheat_to_string((Cheat)q);
372
1/2
✓ Branch 0 taken 1085 times.
✗ Branch 1 not taken.
1085 util::lowerstr(cheatname);
373 1085 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
374
1/2
✓ Branch 0 taken 1085 times.
✗ Branch 1 not taken.
1085 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
375 1085 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
376
1/2
✓ Branch 0 taken 1085 times.
✗ Branch 1 not taken.
1085 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
377 1085 }
378
379
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
380 joystick_index = 0;
381
382 31 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
383 31 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
384 31 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
385 31 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
386 31 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
387 31 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
388 31 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
389 31 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
390 31 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
391 31 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
392
393 31 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
394 31 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
395 31 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
396 31 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
397
398 31 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
399 31 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
400 31 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
401 31 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
402 31 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
403 31 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
404 31 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
405 31 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
406 31 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
407 31 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
408 31 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
409
410 31 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
411 31 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
412 31 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
413 31 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
414
415 31 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
416
417 31 digi_volume = zc_get_config(sfx_sect,"digi",248);
418 31 midi_volume = zc_get_config(sfx_sect,"midi",255);
419 31 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
420 31 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
421 31 pan_style = zc_get_config(sfx_sect,"pan",1);
422 // 1 <= zcmusic_bufsz <= 128
423 31 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
424 31 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
425 31 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
426 31 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
427 31 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
428 31 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
429 31 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
430 #ifdef __EMSCRIPTEN__
431 if (em_is_mobile()) NameEntryMode = 2;
432 #endif
433 31 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
434 31 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
435 31 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
436 31 title_version = zc_get_config(cfg_sect,"title",2);
437 31 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
438 31 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
439
440 //default - scale x2, 640 x 480
441 31 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
442 31 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
443 31 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
444 31 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
445 31 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
446 31 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
447 31 stretchGame = zc_get_config("zeldadx","stretch_game_area",0)!=0;
448
449 31 loadlast = zc_get_config(cfg_sect,"load_last",0);
450
451 31 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
452
453 31 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
454
455 31 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
456 31 info_opacity = zc_get_config("zc","debug_info_opacity",255);
457 #ifdef _WIN32
458 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
459 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
460 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
461 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
462
463 // This one's for Aero
464 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
465
466 // And this one fixes patches unloading on some MIDI setups
467 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
468 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
469 #else //UNIX
470 31 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
471 31 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
472 31 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
473 #endif
474 31 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
475 31 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
476
477 31 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,""));
478
479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(strlen(qstdir)==0)
480 {
481 31 getcwd(qstdir,2048);
482 31 fix_filename_case(qstdir);
483 31 fix_filename_slashes(qstdir);
484 31 put_backslash(qstdir);
485 31 }
486 else
487 {
488 chop_path(qstdir);
489 }
490
491 31 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
492 31 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
493 31 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
494 31 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
495 31 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
496 31 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
497 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
498 31 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
499 31 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
500 31 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
501 31 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
502 31 }
503
504 void save_control_configs(bool kb)
505 {
506 if(kb)
507 {
508 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
509 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
510 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
511 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
512
513 if (!replay_is_replaying())
514 {
515 zc_set_config(ctrl_sect,"key_a",Akey);
516 zc_set_config(ctrl_sect,"key_b",Bkey);
517 zc_set_config(ctrl_sect,"key_s",Skey);
518 zc_set_config(ctrl_sect,"key_l",Lkey);
519 zc_set_config(ctrl_sect,"key_r",Rkey);
520 zc_set_config(ctrl_sect,"key_p",Pkey);
521 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
522 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
523 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
524 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
525 zc_set_config(ctrl_sect,"key_up", DUkey);
526 zc_set_config(ctrl_sect,"key_down", DDkey);
527 zc_set_config(ctrl_sect,"key_left", DLkey);
528 zc_set_config(ctrl_sect,"key_right",DRkey);
529 }
530 }
531 else
532 {
533 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
534 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
535 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
536 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
537 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
538 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
539 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
540 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
541 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
542 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
543 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
544 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
545 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
546 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
547
548 zc_set_config(ctrl_sect,"btn_a",Abtn);
549 zc_set_config(ctrl_sect,"btn_b",Bbtn);
550 zc_set_config(ctrl_sect,"btn_s",Sbtn);
551 zc_set_config(ctrl_sect,"btn_m",Mbtn);
552 zc_set_config(ctrl_sect,"btn_l",Lbtn);
553 zc_set_config(ctrl_sect,"btn_r",Rbtn);
554 zc_set_config(ctrl_sect,"btn_p",Pbtn);
555 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
556 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
557 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
558 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
559
560 zc_set_config(ctrl_sect,"btn_up",DUbtn);
561 zc_set_config(ctrl_sect,"btn_down",DDbtn);
562 zc_set_config(ctrl_sect,"btn_left",DLbtn);
563 zc_set_config(ctrl_sect,"btn_right",DRbtn);
564 }
565 }
566
567 void save_cheatkeys()
568 {
569 char buf[256];
570 for(size_t q = 1; q < Cheat::Last; ++q)
571 {
572 if(!bindable_cheat((Cheat)q)) continue;
573 std::string cheatname = cheat_to_string((Cheat)q);
574 util::lowerstr(cheatname);
575 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
576 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
577 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
578 if(cheatkeys[q][1])
579 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
580 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
581 }
582 }
583
584 void save_game_configs()
585 {
586 packfile_password("");
587
588 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
589
590 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
591 {
592 int o_window_x, o_window_y;
593 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
594 zc_set_config(cfg_sect,"window_x",o_window_x);
595 zc_set_config(cfg_sect,"window_y",o_window_y);
596 }
597
598 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
599 {
600 double monitor_scale = zc_get_monitor_scale();
601 window_width = al_get_display_width(all_get_display()) / monitor_scale;
602 window_height = al_get_display_height(all_get_display()) / monitor_scale;
603 zc_set_config(cfg_sect,"window_width",window_width);
604 zc_set_config(cfg_sect,"window_height",window_height);
605 }
606
607 zc_set_config(cfg_sect,"load_last",loadlast);
608 chop_path(qstdir);
609 zc_set_config(cfg_sect,qst_dir_name,qstdir);
610 zc_set_config("SAVEFILE","save_filename",save_file_name);
611 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
612
613 flush_config_file();
614 #ifdef __EMSCRIPTEN__
615 em_sync_fs();
616 #endif
617 }
618
619 //----------------------------------------------------------------
620
621 // Timers
622
623 26343 void fps_callback()
624 {
625 26343 lastfps=framecnt;
626 26343 dword tempsecs = fps_secs;
627 26343 ++tempsecs;
628 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
629 26343 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
630 26343 ++fps_secs;
631 26343 framecnt=0;
632 26343 }
633
634 END_OF_FUNCTION(fps_callback)
635
636 31 int32_t Z_init_timers()
637 {
638 static bool didit = false;
639 const static char *err_str = "Couldn't allocate timer";
640 31 err_str = err_str; //Unused variable warning
641
642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(didit)
643 return 1;
644
645 31 didit = true;
646
647 LOCK_VARIABLE(lastfps);
648 LOCK_VARIABLE(framecnt);
649 LOCK_FUNCTION(fps_callback);
650
651
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
652 return 0;
653
654 31 return 1;
655 31 }
656
657 void Z_remove_timers()
658 {
659 remove_int(fps_callback);
660 }
661
662 //----------------------------------------------------------------
663
664 void go()
665 {
666 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
667 }
668
669 void comeback()
670 {
671 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
672 }
673
674 void dump_pal(BITMAP *dest)
675 {
676 for(int32_t i=0; i<256; i++)
677 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
678 }
679
680 //----------------------------------------------------------------
681
682 int game_mouse_index = ZCM_BLANK;
683 static bool system_mouse = false;
684 14 bool sys_mouse()
685 {
686 14 system_mouse = true;
687 14 return MouseSprite::set(ZCM_NORMAL);
688 }
689 377 bool game_mouse()
690 {
691 377 system_mouse = false;
692 377 return MouseSprite::set(game_mouse_index);
693 }
694 void custom_mouse(BITMAP* bmp, int fx, int fy, bool sys_recolor, bool user_scale)
695 {
696 if(!bmp)
697 return;
698 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
699 int scaledw = bmp->w*scale, scaledh = bmp->h*scale;
700 if(bmp->w == scaledw && bmp->h == scaledh)
701 user_scale = false;
702 if(user_scale || sys_recolor)
703 {
704 if(!user_scale) scale = 1;
705 BITMAP* tmpbmp = create_bitmap_ex(8,bmp->w*scale,bmp->h*scale);
706 if(user_scale)
707 stretch_blit(bmp, tmpbmp, 0, 0, bmp->w, bmp->h, 0, 0, tmpbmp->w, tmpbmp->h);
708 else
709 blit(bmp, tmpbmp, 0, 0, 0, 0, bmp->w, bmp->h);
710 if(sys_recolor)
711 recolor_mouse(tmpbmp);
712 MouseSprite::assign(ZCM_CUSTOM, tmpbmp, fx*scale, fy*scale);
713 destroy_bitmap(tmpbmp);
714 }
715 else
716 {
717 MouseSprite::assign(ZCM_CUSTOM, bmp, fx, fy);
718 }
719 if(!system_mouse && game_mouse_index == ZCM_CUSTOM)
720 MouseSprite::set(ZCM_CUSTOM); //Reload the new sprite
721 }
722
723 //Handles converting the mouse sprite from the .dat file
724 31 void recolor_mouse(BITMAP* bmp)
725 {
726
2/2
✓ Branch 0 taken 496 times.
✓ Branch 1 taken 31 times.
527 for(int32_t x = 0; x < bmp->w; ++x)
727 {
728
2/2
✓ Branch 0 taken 7936 times.
✓ Branch 1 taken 496 times.
8432 for(int32_t y = 0; y < bmp->h; ++y)
729 {
730 7936 int32_t color = getpixel(bmp, x, y);
731
5/5
✓ Branch 0 taken 5394 times.
✓ Branch 1 taken 589 times.
✓ Branch 2 taken 682 times.
✓ Branch 3 taken 713 times.
✓ Branch 4 taken 558 times.
7936 switch(color)
732 {
733 case dvc(1):
734 589 color = jwin_pal[jcCURSORMISC];
735 589 break;
736 case dvc(2):
737 682 color = jwin_pal[jcCURSOROUTLINE];
738 682 break;
739 case dvc(3):
740 713 color = jwin_pal[jcCURSORLIGHT];
741 713 break;
742 case dvc(5):
743 558 color = jwin_pal[jcCURSORDARK];
744 558 break;
745 default:
746 5394 continue;
747 }
748 2542 putpixel(bmp, x, y, color);
749 2542 }
750 496 }
751 31 }
752 31 void load_mouse()
753 {
754 31 system_pal();
755 31 MouseSprite::set(-1);
756 31 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
757 31 int32_t sz = 16*scale;
758
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 31 times.
62 for(int32_t j = 0; j < 1; ++j)
759 {
760 31 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
761
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(zcmouse[j])
762 destroy_bitmap(zcmouse[j]);
763 31 zcmouse[j] = create_bitmap_ex(8,sz,sz);
764 31 clear_bitmap(zcmouse[j]);
765 31 clear_bitmap(tmpbmp);
766 31 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
767 31 recolor_mouse(tmpbmp);
768
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(sz!=16)
769 31 stretch_blit(tmpbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
770 else
771 blit(tmpbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
772 31 destroy_bitmap(tmpbmp);
773 31 }
774 31 zc_set_palette(*hw_palette);
775
776 31 BITMAP* blankmouse = create_bitmap_ex(8,16,16);
777 31 clear_bitmap(blankmouse);
778
779 31 MouseSprite::assign(ZCM_NORMAL, zcmouse[0], 1*scale, 1*scale);
780 31 MouseSprite::assign(ZCM_BLANK, blankmouse);
781 //Don't assign ZCM_CUSTOM. That'll be handled by scripts.
782
783 //Reload the mouse
784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(system_mouse)
785 sys_mouse();
786 31 else game_mouse();
787
788 31 destroy_bitmap(blankmouse);
789 31 game_pal();
790 31 }
791
792 // sets the video mode and initializes the palette and mouse sprite
793 31 bool game_vid_mode(int32_t mode,int32_t wait)
794 {
795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
796 {
797 return false;
798 }
799
800 31 scrx = (resx-320)>>1;
801 31 scry = (resy-240)>>1;
802
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 31 times.
62 for(int32_t q = 0; q < NUM_ZCMOUSE; ++q)
803 31 zcmouse[q] = NULL;
804 31 load_mouse();
805
806
2/2
✓ Branch 0 taken 496 times.
✓ Branch 1 taken 31 times.
527 for(int32_t i=240; i<256; i++)
807 496 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
808
809 31 zc_set_palette(RAMpal);
810 31 clear_to_color(screen,BLACK);
811
812 31 rest(wait);
813 31 return true;
814 31 }
815
816 6 void null_quest()
817 {
818 char qstdat_string[2048];
819 6 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
820 6 strcat(qstdat_string,"#NESQST_NEW_QST");
821
822 #ifdef __EMSCRIPTEN__
823 // The quest template data file is not included because it's really big and isn't really needed
824 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
825 // which is much smaller.
826 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
827 #endif
828
829 6 byte skip_flags[4] = { 0 };
830
831 6 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,true,true,skip_flags,0,false);
832 6 }
833
834 6 void init_NES_mode()
835 {
836 /*
837 // qst.dat may not load correctly without this...
838 QHeader.templatepath[0]='\0';
839
840 if(!init_colordata(true, &QHeader, &QMisc))
841 {
842 return;
843 }
844
845 loadfullpal();
846 init_tiles(false, &QHeader);
847 */
848 6 null_quest();
849 6 }
850
851 //----------------------------------------------------------------
852
853 qword trianglelines[16]=
854 {
855 0x0000000000000000ULL,
856 0xFD00000000000000ULL,
857 0xFDFD000000000000ULL,
858 0xFDFDFD0000000000ULL,
859 0xFDFDFDFD00000000ULL,
860 0xFDFDFDFDFD000000ULL,
861 0xFDFDFDFDFDFD0000ULL,
862 0xFDFDFDFDFDFDFD00ULL,
863 0xFDFDFDFDFDFDFDFDULL,
864 0x00FDFDFDFDFDFDFDULL,
865 0x0000FDFDFDFDFDFDULL,
866 0x000000FDFDFDFDFDULL,
867 0x00000000FDFDFDFDULL,
868 0x0000000000FDFDFDULL,
869 0x000000000000FDFDULL,
870 0x00000000000000FDULL,
871 };
872
873 word screen_triangles[28][32];
874 /*
875 qword triangles[4][16]= //[direction][value]
876 {
877 {
878 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
879 },
880 {
881 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
882 },
883 {
884 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
885 },
886 {
887 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
888 }
889 };
890 */
891
892
893 /*
894 byte triangles[4][16][8]= //[direction][value][line]
895 {
896 {
897 {
898 0, 0, 0, 0, 0, 0, 0, 0
899 },
900 {
901 1, 0, 0, 0, 0, 0, 0, 0
902 },
903 {
904 2, 1, 0, 0, 0, 0, 0, 0
905 },
906 {
907 3, 2, 1, 0, 0, 0, 0, 0
908 },
909 {
910 4, 3, 2, 1, 0, 0, 0, 0
911 },
912 {
913 5, 4, 3, 2, 1, 0, 0, 0
914 },
915 {
916 6, 5, 4, 3, 2, 1, 0, 0
917 },
918 {
919 7, 6, 5, 4, 3, 2, 1, 0
920 },
921 {
922 8, 7, 6, 5, 4, 3, 2, 1
923 },
924 {
925 8, 8, 7, 6, 5, 4, 3, 2
926 },
927 {
928 8, 8, 8, 7, 6, 5, 4, 3
929 },
930 {
931 8, 8, 8, 8, 7, 6, 5, 4
932 },
933 {
934 8, 8, 8, 8, 8, 7, 6, 5
935 },
936 {
937 8, 8, 8, 8, 8, 8, 7, 6
938 },
939 {
940 8, 8, 8, 8, 8, 8, 8, 7
941 },
942 {
943 8, 8, 8, 8, 8, 8, 8, 8
944 }
945 },
946 {
947 {
948 0, 0, 0, 0, 0, 0, 0, 0
949 },
950 {
951 15, 0, 0, 0, 0, 0, 0, 0
952 },
953 {
954 14, 15, 0, 0, 0, 0, 0, 0
955 },
956 {
957 13, 14, 15, 0, 0, 0, 0, 0
958 },
959 {
960 12, 13, 14, 15, 0, 0, 0, 0
961 },
962 {
963 11, 12, 13, 14, 15, 0, 0, 0
964 },
965 {
966 10, 11, 12, 13, 14, 15, 0, 0
967 },
968 {
969 9, 10, 11, 12, 13, 14, 15, 0
970 },
971 {
972 8, 9, 10, 11, 12, 13, 14, 15
973 },
974 {
975 8, 8, 9, 10, 11, 12, 13, 14
976 },
977 {
978 8, 8, 8, 9, 10, 11, 12, 13
979 },
980 {
981 8, 8, 8, 8, 9, 10, 11, 12
982 },
983 {
984 8, 8, 8, 8, 8, 9, 10, 11
985 },
986 {
987 8, 8, 8, 8, 8, 8, 9, 10
988 },
989 {
990 8, 8, 8, 8, 8, 8, 8, 9
991 },
992 {
993 8, 8, 8, 8, 8, 8, 8, 8
994 }
995 },
996 {
997 {
998 0, 0, 0, 0, 0, 0, 0, 0
999 },
1000 {
1001 0, 0, 0, 0, 0, 0, 0, 1
1002 },
1003 {
1004 0, 0, 0, 0, 0, 0, 1, 2
1005 },
1006 {
1007 0, 0, 0, 0, 0, 1, 2, 3
1008 },
1009 {
1010 0, 0, 0, 0, 1, 2, 3, 4
1011 },
1012 {
1013 0, 0, 0, 1, 2, 3, 4, 5
1014 },
1015 {
1016 0, 0, 1, 2, 3, 4, 5, 6
1017 },
1018 {
1019 0, 1, 2, 3, 4, 5, 6, 7
1020 },
1021 {
1022 1, 2, 3, 4, 5, 6, 7, 8
1023 },
1024 {
1025 2, 3, 4, 5, 6, 7, 8, 8
1026 },
1027 {
1028 3, 4, 5, 6, 7, 8, 8, 8
1029 },
1030 {
1031 4, 5, 6, 7, 8, 8, 8, 8
1032 },
1033 {
1034 5, 6, 7, 8, 8, 8, 8, 8
1035 },
1036 {
1037 6, 7, 8, 8, 8, 8, 8, 8
1038 },
1039 {
1040 7, 8, 8, 8, 8, 8, 8, 8
1041 },
1042 {
1043 8, 8, 8, 8, 8, 8, 8, 8
1044 }
1045 },
1046 {
1047 {
1048 0, 0, 0, 0, 0, 0, 0, 0
1049 },
1050 {
1051 0, 0, 0, 0, 0, 0, 0, 15
1052 },
1053 {
1054 0, 0, 0, 0, 0, 0, 15, 14
1055 },
1056 {
1057 0, 0, 0, 0, 0, 15, 14, 13
1058 },
1059 {
1060 0, 0, 0, 0, 15, 14, 13, 12
1061 },
1062 {
1063 0, 0, 0, 15, 14, 13, 12, 11
1064 },
1065 {
1066 0, 0, 15, 14, 13, 12, 11, 10
1067 },
1068 {
1069 0, 15, 14, 13, 12, 11, 10, 9
1070 },
1071 {
1072 15, 14, 13, 12, 11, 10, 9, 8
1073 },
1074 {
1075 14, 13, 12, 11, 10, 9, 8, 8
1076 },
1077 {
1078 13, 12, 11, 10, 9, 8, 8, 8
1079 },
1080 {
1081 12, 11, 10, 9, 8, 8, 8, 8
1082 },
1083 {
1084 11, 10, 9, 8, 8, 8, 8, 8
1085 },
1086 {
1087 10, 9, 8, 8, 8, 8, 8, 8
1088 },
1089 {
1090 9, 8, 8, 8, 8, 8, 8, 8
1091 },
1092 {
1093 8, 8, 8, 8, 8, 8, 8, 8
1094 }
1095 }
1096 };
1097 */
1098
1099
1100
1101 /*
1102 for (int32_t blockrow=0; blockrow<30; ++i)
1103 {
1104 for (int32_t linerow=0; linerow<8; ++i)
1105 {
1106 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1107 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1108 {
1109 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1110 ++triangleline;
1111 }
1112 }
1113 }
1114 */
1115
1116 // the ULL suffixes are to prevent this warning:
1117 // warning: integer constant is too large for "int32_t" type
1118
1119 qword triangles[4][16][8]= //[direction][value][line]
1120 {
1121 {
1122 {
1123 0x0000000000000000ULL,
1124 0x0000000000000000ULL,
1125 0x0000000000000000ULL,
1126 0x0000000000000000ULL,
1127 0x0000000000000000ULL,
1128 0x0000000000000000ULL,
1129 0x0000000000000000ULL,
1130 0x0000000000000000ULL
1131 },
1132 {
1133 0xFD00000000000000ULL,
1134 0x0000000000000000ULL,
1135 0x0000000000000000ULL,
1136 0x0000000000000000ULL,
1137 0x0000000000000000ULL,
1138 0x0000000000000000ULL,
1139 0x0000000000000000ULL,
1140 0x0000000000000000ULL
1141 },
1142 {
1143 0xFDFD000000000000ULL,
1144 0xFD00000000000000ULL,
1145 0x0000000000000000ULL,
1146 0x0000000000000000ULL,
1147 0x0000000000000000ULL,
1148 0x0000000000000000ULL,
1149 0x0000000000000000ULL,
1150 0x0000000000000000ULL
1151 },
1152 {
1153 0xFDFDFD0000000000ULL,
1154 0xFDFD000000000000ULL,
1155 0xFD00000000000000ULL,
1156 0x0000000000000000ULL,
1157 0x0000000000000000ULL,
1158 0x0000000000000000ULL,
1159 0x0000000000000000ULL,
1160 0x0000000000000000ULL
1161 },
1162 {
1163 0xFDFDFDFD00000000ULL,
1164 0xFDFDFD0000000000ULL,
1165 0xFDFD000000000000ULL,
1166 0xFD00000000000000ULL,
1167 0x0000000000000000ULL,
1168 0x0000000000000000ULL,
1169 0x0000000000000000ULL,
1170 0x0000000000000000ULL
1171 },
1172 {
1173 0xFDFDFDFDFD000000ULL,
1174 0xFDFDFDFD00000000ULL,
1175 0xFDFDFD0000000000ULL,
1176 0xFDFD000000000000ULL,
1177 0xFD00000000000000ULL,
1178 0x0000000000000000ULL,
1179 0x0000000000000000ULL,
1180 0x0000000000000000ULL
1181 },
1182 {
1183 0xFDFDFDFDFDFD0000ULL,
1184 0xFDFDFDFDFD000000ULL,
1185 0xFDFDFDFD00000000ULL,
1186 0xFDFDFD0000000000ULL,
1187 0xFDFD000000000000ULL,
1188 0xFD00000000000000ULL,
1189 0x0000000000000000ULL,
1190 0x0000000000000000ULL
1191 },
1192 {
1193 0xFDFDFDFDFDFDFD00ULL,
1194 0xFDFDFDFDFDFD0000ULL,
1195 0xFDFDFDFDFD000000ULL,
1196 0xFDFDFDFD00000000ULL,
1197 0xFDFDFD0000000000ULL,
1198 0xFDFD000000000000ULL,
1199 0xFD00000000000000ULL,
1200 0x0000000000000000ULL
1201 },
1202 {
1203 0xFDFDFDFDFDFDFDFDULL,
1204 0xFDFDFDFDFDFDFD00ULL,
1205 0xFDFDFDFDFDFD0000ULL,
1206 0xFDFDFDFDFD000000ULL,
1207 0xFDFDFDFD00000000ULL,
1208 0xFDFDFD0000000000ULL,
1209 0xFDFD000000000000ULL,
1210 0xFD00000000000000ULL
1211 },
1212 {
1213 0xFDFDFDFDFDFDFDFDULL,
1214 0xFDFDFDFDFDFDFDFDULL,
1215 0xFDFDFDFDFDFDFD00ULL,
1216 0xFDFDFDFDFDFD0000ULL,
1217 0xFDFDFDFDFD000000ULL,
1218 0xFDFDFDFD00000000ULL,
1219 0xFDFDFD0000000000ULL,
1220 0xFDFD000000000000ULL
1221 },
1222 {
1223 0xFDFDFDFDFDFDFDFDULL,
1224 0xFDFDFDFDFDFDFDFDULL,
1225 0xFDFDFDFDFDFDFDFDULL,
1226 0xFDFDFDFDFDFDFD00ULL,
1227 0xFDFDFDFDFDFD0000ULL,
1228 0xFDFDFDFDFD000000ULL,
1229 0xFDFDFDFD00000000ULL,
1230 0xFDFDFD0000000000ULL
1231 },
1232 {
1233 0xFDFDFDFDFDFDFDFDULL,
1234 0xFDFDFDFDFDFDFDFDULL,
1235 0xFDFDFDFDFDFDFDFDULL,
1236 0xFDFDFDFDFDFDFDFDULL,
1237 0xFDFDFDFDFDFDFD00ULL,
1238 0xFDFDFDFDFDFD0000ULL,
1239 0xFDFDFDFDFD000000ULL,
1240 0xFDFDFDFD00000000ULL
1241 },
1242 {
1243 0xFDFDFDFDFDFDFDFDULL,
1244 0xFDFDFDFDFDFDFDFDULL,
1245 0xFDFDFDFDFDFDFDFDULL,
1246 0xFDFDFDFDFDFDFDFDULL,
1247 0xFDFDFDFDFDFDFDFDULL,
1248 0xFDFDFDFDFDFDFD00ULL,
1249 0xFDFDFDFDFDFD0000ULL,
1250 0xFDFDFDFDFD000000ULL
1251 },
1252 {
1253 0xFDFDFDFDFDFDFDFDULL,
1254 0xFDFDFDFDFDFDFDFDULL,
1255 0xFDFDFDFDFDFDFDFDULL,
1256 0xFDFDFDFDFDFDFDFDULL,
1257 0xFDFDFDFDFDFDFDFDULL,
1258 0xFDFDFDFDFDFDFDFDULL,
1259 0xFDFDFDFDFDFDFD00ULL,
1260 0xFDFDFDFDFDFD0000ULL
1261 },
1262 {
1263 0xFDFDFDFDFDFDFDFDULL,
1264 0xFDFDFDFDFDFDFDFDULL,
1265 0xFDFDFDFDFDFDFDFDULL,
1266 0xFDFDFDFDFDFDFDFDULL,
1267 0xFDFDFDFDFDFDFDFDULL,
1268 0xFDFDFDFDFDFDFDFDULL,
1269 0xFDFDFDFDFDFDFDFDULL,
1270 0xFDFDFDFDFDFDFD00ULL
1271 },
1272 {
1273 0xFDFDFDFDFDFDFDFDULL,
1274 0xFDFDFDFDFDFDFDFDULL,
1275 0xFDFDFDFDFDFDFDFDULL,
1276 0xFDFDFDFDFDFDFDFDULL,
1277 0xFDFDFDFDFDFDFDFDULL,
1278 0xFDFDFDFDFDFDFDFDULL,
1279 0xFDFDFDFDFDFDFDFDULL,
1280 0xFDFDFDFDFDFDFDFDULL
1281 }
1282 },
1283 {
1284 {
1285 0x0000000000000000ULL,
1286 0x0000000000000000ULL,
1287 0x0000000000000000ULL,
1288 0x0000000000000000ULL,
1289 0x0000000000000000ULL,
1290 0x0000000000000000ULL,
1291 0x0000000000000000ULL,
1292 0x0000000000000000ULL
1293 },
1294 {
1295 0x00000000000000FDULL,
1296 0x0000000000000000ULL,
1297 0x0000000000000000ULL,
1298 0x0000000000000000ULL,
1299 0x0000000000000000ULL,
1300 0x0000000000000000ULL,
1301 0x0000000000000000ULL,
1302 0x0000000000000000ULL
1303 },
1304 {
1305 0x000000000000FDFDULL,
1306 0x00000000000000FDULL,
1307 0x0000000000000000ULL,
1308 0x0000000000000000ULL,
1309 0x0000000000000000ULL,
1310 0x0000000000000000ULL,
1311 0x0000000000000000ULL,
1312 0x0000000000000000ULL
1313 },
1314 {
1315 0x0000000000FDFDFDULL,
1316 0x000000000000FDFDULL,
1317 0x00000000000000FDULL,
1318 0x0000000000000000ULL,
1319 0x0000000000000000ULL,
1320 0x0000000000000000ULL,
1321 0x0000000000000000ULL,
1322 0x0000000000000000ULL
1323 },
1324 {
1325 0x00000000FDFDFDFDULL,
1326 0x0000000000FDFDFDULL,
1327 0x000000000000FDFDULL,
1328 0x00000000000000FDULL,
1329 0x0000000000000000ULL,
1330 0x0000000000000000ULL,
1331 0x0000000000000000ULL,
1332 0x0000000000000000ULL
1333 },
1334 {
1335 0x000000FDFDFDFDFDULL,
1336 0x00000000FDFDFDFDULL,
1337 0x0000000000FDFDFDULL,
1338 0x000000000000FDFDULL,
1339 0x00000000000000FDULL,
1340 0x0000000000000000ULL,
1341 0x0000000000000000ULL,
1342 0x0000000000000000ULL
1343 },
1344 {
1345 0x0000FDFDFDFDFDFDULL,
1346 0x000000FDFDFDFDFDULL,
1347 0x00000000FDFDFDFDULL,
1348 0x0000000000FDFDFDULL,
1349 0x000000000000FDFDULL,
1350 0x00000000000000FDULL,
1351 0x0000000000000000ULL,
1352 0x0000000000000000ULL
1353 },
1354 {
1355 0x00FDFDFDFDFDFDFDULL,
1356 0x0000FDFDFDFDFDFDULL,
1357 0x000000FDFDFDFDFDULL,
1358 0x00000000FDFDFDFDULL,
1359 0x0000000000FDFDFDULL,
1360 0x000000000000FDFDULL,
1361 0x00000000000000FDULL,
1362 0x0000000000000000ULL
1363 },
1364 {
1365 0xFDFDFDFDFDFDFDFDULL,
1366 0x00FDFDFDFDFDFDFDULL,
1367 0x0000FDFDFDFDFDFDULL,
1368 0x000000FDFDFDFDFDULL,
1369 0x00000000FDFDFDFDULL,
1370 0x0000000000FDFDFDULL,
1371 0x000000000000FDFDULL,
1372 0x00000000000000FDULL
1373 },
1374 {
1375 0xFDFDFDFDFDFDFDFDULL,
1376 0xFDFDFDFDFDFDFDFDULL,
1377 0x00FDFDFDFDFDFDFDULL,
1378 0x0000FDFDFDFDFDFDULL,
1379 0x000000FDFDFDFDFDULL,
1380 0x00000000FDFDFDFDULL,
1381 0x0000000000FDFDFDULL,
1382 0x000000000000FDFDULL
1383 },
1384 {
1385 0xFDFDFDFDFDFDFDFDULL,
1386 0xFDFDFDFDFDFDFDFDULL,
1387 0xFDFDFDFDFDFDFDFDULL,
1388 0x00FDFDFDFDFDFDFDULL,
1389 0x0000FDFDFDFDFDFDULL,
1390 0x000000FDFDFDFDFDULL,
1391 0x00000000FDFDFDFDULL,
1392 0x0000000000FDFDFDULL
1393 },
1394 {
1395 0xFDFDFDFDFDFDFDFDULL,
1396 0xFDFDFDFDFDFDFDFDULL,
1397 0xFDFDFDFDFDFDFDFDULL,
1398 0xFDFDFDFDFDFDFDFDULL,
1399 0x00FDFDFDFDFDFDFDULL,
1400 0x0000FDFDFDFDFDFDULL,
1401 0x000000FDFDFDFDFDULL,
1402 0x00000000FDFDFDFDULL
1403 },
1404 {
1405 0xFDFDFDFDFDFDFDFDULL,
1406 0xFDFDFDFDFDFDFDFDULL,
1407 0xFDFDFDFDFDFDFDFDULL,
1408 0xFDFDFDFDFDFDFDFDULL,
1409 0xFDFDFDFDFDFDFDFDULL,
1410 0x00FDFDFDFDFDFDFDULL,
1411 0x0000FDFDFDFDFDFDULL,
1412 0x000000FDFDFDFDFDULL
1413 },
1414 {
1415 0xFDFDFDFDFDFDFDFDULL,
1416 0xFDFDFDFDFDFDFDFDULL,
1417 0xFDFDFDFDFDFDFDFDULL,
1418 0xFDFDFDFDFDFDFDFDULL,
1419 0xFDFDFDFDFDFDFDFDULL,
1420 0xFDFDFDFDFDFDFDFDULL,
1421 0x00FDFDFDFDFDFDFDULL,
1422 0x0000FDFDFDFDFDFDULL
1423 },
1424 {
1425 0xFDFDFDFDFDFDFDFDULL,
1426 0xFDFDFDFDFDFDFDFDULL,
1427 0xFDFDFDFDFDFDFDFDULL,
1428 0xFDFDFDFDFDFDFDFDULL,
1429 0xFDFDFDFDFDFDFDFDULL,
1430 0xFDFDFDFDFDFDFDFDULL,
1431 0xFDFDFDFDFDFDFDFDULL,
1432 0x00FDFDFDFDFDFDFDULL
1433 },
1434 {
1435 0xFDFDFDFDFDFDFDFDULL,
1436 0xFDFDFDFDFDFDFDFDULL,
1437 0xFDFDFDFDFDFDFDFDULL,
1438 0xFDFDFDFDFDFDFDFDULL,
1439 0xFDFDFDFDFDFDFDFDULL,
1440 0xFDFDFDFDFDFDFDFDULL,
1441 0xFDFDFDFDFDFDFDFDULL,
1442 0xFDFDFDFDFDFDFDFDULL
1443 }
1444 },
1445 {
1446 {
1447 0x0000000000000000ULL,
1448 0x0000000000000000ULL,
1449 0x0000000000000000ULL,
1450 0x0000000000000000ULL,
1451 0x0000000000000000ULL,
1452 0x0000000000000000ULL,
1453 0x0000000000000000ULL,
1454 0x0000000000000000ULL
1455 },
1456 {
1457 0x0000000000000000ULL,
1458 0x0000000000000000ULL,
1459 0x0000000000000000ULL,
1460 0x0000000000000000ULL,
1461 0x0000000000000000ULL,
1462 0x0000000000000000ULL,
1463 0x0000000000000000ULL,
1464 0xFD00000000000000ULL
1465 },
1466 {
1467 0x0000000000000000ULL,
1468 0x0000000000000000ULL,
1469 0x0000000000000000ULL,
1470 0x0000000000000000ULL,
1471 0x0000000000000000ULL,
1472 0x0000000000000000ULL,
1473 0xFD00000000000000ULL,
1474 0xFDFD000000000000ULL
1475 },
1476 {
1477 0x0000000000000000ULL,
1478 0x0000000000000000ULL,
1479 0x0000000000000000ULL,
1480 0x0000000000000000ULL,
1481 0x0000000000000000ULL,
1482 0xFD00000000000000ULL,
1483 0xFDFD000000000000ULL,
1484 0xFDFDFD0000000000ULL
1485 },
1486 {
1487 0x0000000000000000ULL,
1488 0x0000000000000000ULL,
1489 0x0000000000000000ULL,
1490 0x0000000000000000ULL,
1491 0xFD00000000000000ULL,
1492 0xFDFD000000000000ULL,
1493 0xFDFDFD0000000000ULL,
1494 0xFDFDFDFD00000000ULL
1495 },
1496 {
1497 0x0000000000000000ULL,
1498 0x0000000000000000ULL,
1499 0x0000000000000000ULL,
1500 0xFD00000000000000ULL,
1501 0xFDFD000000000000ULL,
1502 0xFDFDFD0000000000ULL,
1503 0xFDFDFDFD00000000ULL,
1504 0xFDFDFDFDFD000000ULL
1505 },
1506 {
1507 0x0000000000000000ULL,
1508 0x0000000000000000ULL,
1509 0xFD00000000000000ULL,
1510 0xFDFD000000000000ULL,
1511 0xFDFDFD0000000000ULL,
1512 0xFDFDFDFD00000000ULL,
1513 0xFDFDFDFDFD000000ULL,
1514 0xFDFDFDFDFDFD0000ULL
1515 },
1516 {
1517 0x0000000000000000ULL,
1518 0xFD00000000000000ULL,
1519 0xFDFD000000000000ULL,
1520 0xFDFDFD0000000000ULL,
1521 0xFDFDFDFD00000000ULL,
1522 0xFDFDFDFDFD000000ULL,
1523 0xFDFDFDFDFDFD0000ULL,
1524 0xFDFDFDFDFDFDFD00ULL
1525 },
1526 {
1527 0xFD00000000000000ULL,
1528 0xFDFD000000000000ULL,
1529 0xFDFDFD0000000000ULL,
1530 0xFDFDFDFD00000000ULL,
1531 0xFDFDFDFDFD000000ULL,
1532 0xFDFDFDFDFDFD0000ULL,
1533 0xFDFDFDFDFDFDFD00ULL,
1534 0xFDFDFDFDFDFDFDFDULL
1535 },
1536 {
1537 0xFDFD000000000000ULL,
1538 0xFDFDFD0000000000ULL,
1539 0xFDFDFDFD00000000ULL,
1540 0xFDFDFDFDFD000000ULL,
1541 0xFDFDFDFDFDFD0000ULL,
1542 0xFDFDFDFDFDFDFD00ULL,
1543 0xFDFDFDFDFDFDFDFDULL,
1544 0xFDFDFDFDFDFDFDFDULL
1545 },
1546 {
1547 0xFDFDFD0000000000ULL,
1548 0xFDFDFDFD00000000ULL,
1549 0xFDFDFDFDFD000000ULL,
1550 0xFDFDFDFDFDFD0000ULL,
1551 0xFDFDFDFDFDFDFD00ULL,
1552 0xFDFDFDFDFDFDFDFDULL,
1553 0xFDFDFDFDFDFDFDFDULL,
1554 0xFDFDFDFDFDFDFDFDULL
1555 },
1556 {
1557 0xFDFDFDFD00000000ULL,
1558 0xFDFDFDFDFD000000ULL,
1559 0xFDFDFDFDFDFD0000ULL,
1560 0xFDFDFDFDFDFDFD00ULL,
1561 0xFDFDFDFDFDFDFDFDULL,
1562 0xFDFDFDFDFDFDFDFDULL,
1563 0xFDFDFDFDFDFDFDFDULL,
1564 0xFDFDFDFDFDFDFDFDULL
1565 },
1566 {
1567 0xFDFDFDFDFD000000ULL,
1568 0xFDFDFDFDFDFD0000ULL,
1569 0xFDFDFDFDFDFDFD00ULL,
1570 0xFDFDFDFDFDFDFDFDULL,
1571 0xFDFDFDFDFDFDFDFDULL,
1572 0xFDFDFDFDFDFDFDFDULL,
1573 0xFDFDFDFDFDFDFDFDULL,
1574 0xFDFDFDFDFDFDFDFDULL
1575 },
1576 {
1577 0xFDFDFDFDFDFD0000ULL,
1578 0xFDFDFDFDFDFDFD00ULL,
1579 0xFDFDFDFDFDFDFDFDULL,
1580 0xFDFDFDFDFDFDFDFDULL,
1581 0xFDFDFDFDFDFDFDFDULL,
1582 0xFDFDFDFDFDFDFDFDULL,
1583 0xFDFDFDFDFDFDFDFDULL,
1584 0xFDFDFDFDFDFDFDFDULL
1585 },
1586 {
1587 0xFDFDFDFDFDFDFD00ULL,
1588 0xFDFDFDFDFDFDFDFDULL,
1589 0xFDFDFDFDFDFDFDFDULL,
1590 0xFDFDFDFDFDFDFDFDULL,
1591 0xFDFDFDFDFDFDFDFDULL,
1592 0xFDFDFDFDFDFDFDFDULL,
1593 0xFDFDFDFDFDFDFDFDULL,
1594 0xFDFDFDFDFDFDFDFDULL
1595 },
1596 {
1597 0xFDFDFDFDFDFDFDFDULL,
1598 0xFDFDFDFDFDFDFDFDULL,
1599 0xFDFDFDFDFDFDFDFDULL,
1600 0xFDFDFDFDFDFDFDFDULL,
1601 0xFDFDFDFDFDFDFDFDULL,
1602 0xFDFDFDFDFDFDFDFDULL,
1603 0xFDFDFDFDFDFDFDFDULL,
1604 0xFDFDFDFDFDFDFDFDULL
1605 }
1606 },
1607 {
1608 {
1609 0x0000000000000000ULL,
1610 0x0000000000000000ULL,
1611 0x0000000000000000ULL,
1612 0x0000000000000000ULL,
1613 0x0000000000000000ULL,
1614 0x0000000000000000ULL,
1615 0x0000000000000000ULL,
1616 0x0000000000000000ULL
1617 },
1618 {
1619 0x0000000000000000ULL,
1620 0x0000000000000000ULL,
1621 0x0000000000000000ULL,
1622 0x0000000000000000ULL,
1623 0x0000000000000000ULL,
1624 0x0000000000000000ULL,
1625 0x0000000000000000ULL,
1626 0x00000000000000FDULL
1627 },
1628 {
1629 0x0000000000000000ULL,
1630 0x0000000000000000ULL,
1631 0x0000000000000000ULL,
1632 0x0000000000000000ULL,
1633 0x0000000000000000ULL,
1634 0x0000000000000000ULL,
1635 0x00000000000000FDULL,
1636 0x000000000000FDFDULL
1637 },
1638 {
1639 0x0000000000000000ULL,
1640 0x0000000000000000ULL,
1641 0x0000000000000000ULL,
1642 0x0000000000000000ULL,
1643 0x0000000000000000ULL,
1644 0x00000000000000FDULL,
1645 0x000000000000FDFDULL,
1646 0x0000000000FDFDFDULL
1647 },
1648 {
1649 0x0000000000000000ULL,
1650 0x0000000000000000ULL,
1651 0x0000000000000000ULL,
1652 0x0000000000000000ULL,
1653 0x00000000000000FDULL,
1654 0x000000000000FDFDULL,
1655 0x0000000000FDFDFDULL,
1656 0x00000000FDFDFDFDULL
1657 },
1658 {
1659 0x0000000000000000ULL,
1660 0x0000000000000000ULL,
1661 0x0000000000000000ULL,
1662 0x00000000000000FDULL,
1663 0x000000000000FDFDULL,
1664 0x0000000000FDFDFDULL,
1665 0x00000000FDFDFDFDULL,
1666 0x000000FDFDFDFDFDULL
1667 },
1668 {
1669 0x0000000000000000ULL,
1670 0x0000000000000000ULL,
1671 0x00000000000000FDULL,
1672 0x000000000000FDFDULL,
1673 0x0000000000FDFDFDULL,
1674 0x00000000FDFDFDFDULL,
1675 0x000000FDFDFDFDFDULL,
1676 0x0000FDFDFDFDFDFDULL
1677 },
1678 {
1679 0x0000000000000000ULL,
1680 0x00000000000000FDULL,
1681 0x000000000000FDFDULL,
1682 0x0000000000FDFDFDULL,
1683 0x00000000FDFDFDFDULL,
1684 0x000000FDFDFDFDFDULL,
1685 0x0000FDFDFDFDFDFDULL,
1686 0x00FDFDFDFDFDFDFDULL
1687 },
1688 {
1689 0x00000000000000FDULL,
1690 0x000000000000FDFDULL,
1691 0x0000000000FDFDFDULL,
1692 0x00000000FDFDFDFDULL,
1693 0x000000FDFDFDFDFDULL,
1694 0x0000FDFDFDFDFDFDULL,
1695 0x00FDFDFDFDFDFDFDULL,
1696 0xFDFDFDFDFDFDFDFDULL
1697 },
1698 {
1699 0x000000000000FDFDULL,
1700 0x0000000000FDFDFDULL,
1701 0x00000000FDFDFDFDULL,
1702 0x000000FDFDFDFDFDULL,
1703 0x0000FDFDFDFDFDFDULL,
1704 0x00FDFDFDFDFDFDFDULL,
1705 0xFDFDFDFDFDFDFDFDULL,
1706 0xFDFDFDFDFDFDFDFDULL
1707 },
1708 {
1709 0x0000000000FDFDFDULL,
1710 0x00000000FDFDFDFDULL,
1711 0x000000FDFDFDFDFDULL,
1712 0x0000FDFDFDFDFDFDULL,
1713 0x00FDFDFDFDFDFDFDULL,
1714 0xFDFDFDFDFDFDFDFDULL,
1715 0xFDFDFDFDFDFDFDFDULL,
1716 0xFDFDFDFDFDFDFDFDULL
1717 },
1718 {
1719 0x00000000FDFDFDFDULL,
1720 0x000000FDFDFDFDFDULL,
1721 0x0000FDFDFDFDFDFDULL,
1722 0x00FDFDFDFDFDFDFDULL,
1723 0xFDFDFDFDFDFDFDFDULL,
1724 0xFDFDFDFDFDFDFDFDULL,
1725 0xFDFDFDFDFDFDFDFDULL,
1726 0xFDFDFDFDFDFDFDFDULL
1727 },
1728 {
1729 0x000000FDFDFDFDFDULL,
1730 0x0000FDFDFDFDFDFDULL,
1731 0x00FDFDFDFDFDFDFDULL,
1732 0xFDFDFDFDFDFDFDFDULL,
1733 0xFDFDFDFDFDFDFDFDULL,
1734 0xFDFDFDFDFDFDFDFDULL,
1735 0xFDFDFDFDFDFDFDFDULL,
1736 0xFDFDFDFDFDFDFDFDULL
1737 },
1738 {
1739 0x0000FDFDFDFDFDFDULL,
1740 0x00FDFDFDFDFDFDFDULL,
1741 0xFDFDFDFDFDFDFDFDULL,
1742 0xFDFDFDFDFDFDFDFDULL,
1743 0xFDFDFDFDFDFDFDFDULL,
1744 0xFDFDFDFDFDFDFDFDULL,
1745 0xFDFDFDFDFDFDFDFDULL,
1746 0xFDFDFDFDFDFDFDFDULL
1747 },
1748 {
1749 0x00FDFDFDFDFDFDFDULL,
1750 0xFDFDFDFDFDFDFDFDULL,
1751 0xFDFDFDFDFDFDFDFDULL,
1752 0xFDFDFDFDFDFDFDFDULL,
1753 0xFDFDFDFDFDFDFDFDULL,
1754 0xFDFDFDFDFDFDFDFDULL,
1755 0xFDFDFDFDFDFDFDFDULL,
1756 0xFDFDFDFDFDFDFDFDULL
1757 },
1758 {
1759 0xFDFDFDFDFDFDFDFDULL,
1760 0xFDFDFDFDFDFDFDFDULL,
1761 0xFDFDFDFDFDFDFDFDULL,
1762 0xFDFDFDFDFDFDFDFDULL,
1763 0xFDFDFDFDFDFDFDFDULL,
1764 0xFDFDFDFDFDFDFDFDULL,
1765 0xFDFDFDFDFDFDFDFDULL,
1766 0xFDFDFDFDFDFDFDFDULL
1767 }
1768 }
1769 };
1770
1771 int32_t black_opening_count=0;
1772 int32_t black_opening_x,black_opening_y;
1773 int32_t black_opening_shape;
1774
1775 979 int32_t choose_opening_shape()
1776 {
1777 // First, count how many bits are set
1778 979 int32_t numBits=0;
1779 int32_t bitCounter;
1780
1781
2/2
✓ Branch 0 taken 4895 times.
✓ Branch 1 taken 979 times.
5874 for(int32_t i=0; i<bosMAX; i++)
1782 {
1783
2/2
✓ Branch 0 taken 3700 times.
✓ Branch 1 taken 1195 times.
4895 if(COOLSCROLL&(1<<i))
1784 1195 numBits++;
1785 4895 }
1786
1787 // Shouldn't happen...
1788
1/2
✓ Branch 0 taken 979 times.
✗ Branch 1 not taken.
979 if(numBits==0)
1789 return bosCIRCLE;
1790
1791 // Pick a bit
1792 979 bitCounter=zc_rand()%numBits+1;
1793
1794
2/2
✓ Branch 0 taken 1191 times.
✓ Branch 1 taken 26 times.
1217 for(int32_t i=0; i<bosMAX; i++)
1795 {
1796 // If this bit is set, decrement the bit counter
1797
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 1109 times.
1191 if(COOLSCROLL&(1<<i))
1798 1109 bitCounter--;
1799
1800 // When the counter hits 0, return a value based on
1801 // which bit it stopped on.
1802 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1803
2/2
✓ Branch 0 taken 953 times.
✓ Branch 1 taken 238 times.
1191 if(bitCounter==0)
1804 953 return i;
1805 238 }
1806
1807 // Shouldn't be necessary, but the compiler might complain, at least
1808 26 return bosCIRCLE;
1809 979 }
1810
1811 276 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1812 {
1813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
276 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1814
1815 276 int32_t w=256, h=224;
1816 276 int32_t blockrows=28, blockcolumns=32;
1817 276 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1818
1819
2/2
✓ Branch 0 taken 7728 times.
✓ Branch 1 taken 276 times.
8004 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1820 {
1821
2/2
✓ Branch 0 taken 247296 times.
✓ Branch 1 taken 7728 times.
255024 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1822 {
1823
2/2
✓ Branch 0 taken 132516 times.
✓ Branch 1 taken 114780 times.
247296 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1824 247296 }
1825 7728 }
1826
1827 276 black_opening_count = 66;
1828 276 black_opening_x = x;
1829 276 black_opening_y = y;
1830 276 lensclk = 0;
1831 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1832
1833
1834
1/2
✓ Branch 0 taken 276 times.
✗ Branch 1 not taken.
276 if(black_opening_shape == bosFADEBLACK)
1835 {
1836 refreshTints();
1837 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1838 }
1839
1/2
✓ Branch 0 taken 276 times.
✗ Branch 1 not taken.
276 if(wait)
1840 {
1841 FFCore.warpScriptCheck();
1842 for(int32_t i=0; i<66; i++)
1843 {
1844 draw_screen(tmpscr);
1845 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1846 advanceframe(true);
1847
1848 if(Quit)
1849 {
1850 break;
1851 }
1852 }
1853 }
1854 276 }
1855
1856 703 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1857 {
1858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 703 times.
703 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1859
1860 703 int32_t w=256, h=224;
1861 703 int32_t blockrows=28, blockcolumns=32;
1862 703 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1863
1864
2/2
✓ Branch 0 taken 19684 times.
✓ Branch 1 taken 703 times.
20387 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1865 {
1866
2/2
✓ Branch 0 taken 629888 times.
✓ Branch 1 taken 19684 times.
649572 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1867 {
1868
2/2
✓ Branch 0 taken 289862 times.
✓ Branch 1 taken 340026 times.
629888 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1869 629888 }
1870 19684 }
1871
1872 703 black_opening_count = -66;
1873 703 black_opening_x = x;
1874 703 black_opening_y = y;
1875 703 lensclk = 0;
1876
1/2
✓ Branch 0 taken 703 times.
✗ Branch 1 not taken.
703 if(black_opening_shape == bosFADEBLACK)
1877 {
1878 refreshTints();
1879 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1880 }
1881
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 547 times.
703 if(wait)
1882 {
1883 547 FFCore.warpScriptCheck();
1884
2/2
✓ Branch 0 taken 547 times.
✓ Branch 1 taken 36102 times.
36649 for(int32_t i=0; i<66; i++)
1885 {
1886 36102 draw_screen(tmpscr);
1887 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1888 36102 advanceframe(true);
1889
1890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36102 times.
36102 if(Quit)
1891 {
1892 break;
1893 }
1894 36102 }
1895 547 }
1896 703 }
1897
1898 64614 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1899 {
1900 64614 clear_to_color(tmp_scr,BLACK);
1901 64614 int32_t w=256, h=224;
1902
1903
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 1650 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 61446 times.
64614 switch(black_opening_shape)
1904 {
1905 case bosOVAL:
1906 {
1907 858 double new_w=(w/2)+abs(w/2-x);
1908 858 double new_h=(h/2)+abs(h/2-y);
1909 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1910 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1911 858 break;
1912 }
1913
1914 case bosTRIANGLE:
1915 {
1916 660 double new_w=(w/2)+abs(w/2-x);
1917 660 double new_h=(h/2)+abs(h/2-y);
1918 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1919 660 double P2= (PI/2);
1920 660 double P23=(2*PI/3);
1921 660 double P43=(4*PI/3);
1922 660 double Pa= (-4*PI*a/(3*max_a));
1923 660 double angle=P2+Pa;
1924 660 double a0=angle;
1925 660 double a2=angle+P23;
1926 660 double a4=angle+P43;
1927 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1928 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1929 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1930 0);
1931 660 break;
1932 }
1933
1934 case bosSMAS:
1935 {
1936
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 990 times.
1650 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1937
1938
2/2
✓ Branch 0 taken 46200 times.
✓ Branch 1 taken 1650 times.
47850 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1939 {
1940
2/2
✓ Branch 0 taken 369600 times.
✓ Branch 1 taken 46200 times.
415800 for(int32_t linerow=0; linerow<8; ++linerow)
1941 {
1942 369600 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1943
1944
2/2
✓ Branch 0 taken 11827200 times.
✓ Branch 1 taken 369600 times.
12196800 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1945 {
1946 35481600 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1947
6/6
✓ Branch 0 taken 8249728 times.
✓ Branch 1 taken 3577472 times.
✓ Branch 2 taken 7829672 times.
✓ Branch 3 taken 3997528 times.
✓ Branch 4 taken 4252200 times.
✓ Branch 5 taken 3577472 times.
11827200 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1948 11827200 [linerow];
1949 11827200 ++triangleline;
1950
1951
2/2
✓ Branch 0 taken 10348800 times.
✓ Branch 1 taken 1478400 times.
11827200 if(linerow==0)
1952 {
1953 1478400 }
1954 11827200 }
1955 369600 }
1956 46200 }
1957
1958 1650 break;
1959 }
1960
1961 case bosFADEBLACK:
1962 {
1963 if(black_opening_count<0)
1964 {
1965 black_fade(zc_min(-black_opening_count,63));
1966 }
1967 else if(black_opening_count>0)
1968 {
1969 black_fade(63-zc_max(black_opening_count-3,0));
1970 }
1971 else black_fade(0);
1972 return; //no blitting from tmp_scr!
1973 }
1974
1975 61446 case bosCIRCLE:
1976 default:
1977 {
1978 61446 double new_w=(w/2)+abs(w/2-x);
1979 61446 double new_h=(h/2)+abs(h/2-y);
1980 61446 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1981 //circlefill(tmp_scr,x,y,a<<3,0);
1982 61446 circlefill(tmp_scr,x,y,r,0);
1983 61446 break;
1984 }
1985 }
1986
1987 64614 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1988 64614 }
1989
1990
1991 void black_fade(int32_t fadeamnt)
1992 {
1993 for(int32_t i=0; i < 0xEF; i++)
1994 {
1995 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1996 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1997 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1998 }
1999
2000 refreshpal = true;
2001 }
2002
2003 //----------------------------------------------------------------
2004
2005 17710096 bool item_disabled(int32_t item) //is this item disabled?
2006 {
2007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17710096 times.
17710096 return (item>=0 && game->items_off[item] != 0);
2008 }
2009
2010 6255715 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
2011 {
2012
2/2
✓ Branch 0 taken 57842 times.
✓ Branch 1 taken 6197873 times.
6255715 if(current_item(item_type, true) >=item)
2013 {
2014 57842 return true;
2015 }
2016
2017 6197873 return false;
2018 6255715 }
2019
2020 26033259 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
2021 {
2022
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4763517 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2908079 times.
✓ Branch 6 taken 13819262 times.
✓ Branch 7 taken 4510595 times.
✓ Branch 8 taken 31806 times.
26033259 switch(item_type)
2023 {
2024 case itype_bomb:
2025 case itype_sbomb:
2026 {
2027 int32_t itemid = getItemID(itemsbuf, item_type, it);
2028
2029 if(itemid == -1)
2030 return false;
2031
2032 return (game->get_item(itemid));
2033 }
2034
2035 case itype_clock:
2036 {
2037 4763517 int32_t itemid = getItemID(itemsbuf, item_type, it);
2038
2039
2/4
✓ Branch 0 taken 4763517 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4763517 times.
✗ Branch 3 not taken.
4763517 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
2040 return (game->get_item(itemid));
2041 4763517 return Hero.getClock()?1:0;
2042 }
2043
2044 case itype_key:
2045 return (game->get_keys()>0);
2046
2047 case itype_magiccontainer:
2048 return (game->get_maxmagic()>=game->get_mp_per_block());
2049
2050 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
2051 {
2052
1/3
✓ Branch 0 taken 2908079 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2908079 switch(it)
2053 {
2054 case -2:
2055 {
2056 for(int32_t i=0; i<MAXLEVELS; i++)
2057 {
2058 if(game->lvlitems[i]&liTRIFORCE)
2059 {
2060 return true;
2061 }
2062 }
2063
2064 return false;
2065 }
2066
2067 case -1:
2068 return (game->lvlitems[dlevel]&liTRIFORCE);
2069
2070 default:
2071
2/4
✓ Branch 0 taken 2908079 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2908079 times.
2908079 if(it>=0&&it<MAXLEVELS)
2072 {
2073 2908079 return (game->lvlitems[it]&liTRIFORCE);
2074 }
2075
2076 break;
2077 }
2078
2079 return 0;
2080 }
2081
2082 case itype_map: //it: -2=any, -1=current level, other=that level
2083 {
2084
1/3
✓ Branch 0 taken 13819262 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
13819262 switch(it)
2085 {
2086 case -2:
2087 {
2088 for(int32_t i=0; i<MAXLEVELS; i++)
2089 {
2090 if(game->lvlitems[i]&liMAP)
2091 {
2092 return true;
2093 }
2094 }
2095
2096 return false;
2097 }
2098
2099 case -1:
2100 return (game->lvlitems[dlevel]&liMAP)!=0;
2101
2102 default:
2103
2/4
✓ Branch 0 taken 13819262 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13819262 times.
13819262 if(it>=0&&it<MAXLEVELS)
2104 {
2105 13819262 return (game->lvlitems[it]&liMAP)!=0;
2106 }
2107
2108 break;
2109 }
2110
2111 return 0;
2112 }
2113
2114 case itype_compass: //it: -2=any, -1=current level, other=that level
2115 {
2116
1/3
✓ Branch 0 taken 4510595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
4510595 switch(it)
2117 {
2118 case -2:
2119 {
2120 for(int32_t i=0; i<MAXLEVELS; i++)
2121 {
2122 if(game->lvlitems[i]&liCOMPASS)
2123 {
2124 return true;
2125 }
2126 }
2127
2128 return false;
2129 }
2130
2131 case -1:
2132 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2133
2134 default:
2135
2/4
✓ Branch 0 taken 4510595 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4510595 times.
✗ Branch 3 not taken.
4510595 if(it>=0&&it<MAXLEVELS)
2136 {
2137 4510595 return (game->lvlitems[it]&liCOMPASS)!=0;
2138 }
2139
2140 break;
2141 }
2142 return 0;
2143 }
2144
2145 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2146 {
2147
1/3
✓ Branch 0 taken 31806 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
31806 switch(it)
2148 {
2149 case -2:
2150 {
2151 for(int32_t i=0; i<MAXLEVELS; i++)
2152 {
2153 if(game->lvlitems[i]&liBOSSKEY)
2154 {
2155 return true;
2156 }
2157 }
2158
2159 return false;
2160 }
2161
2162 case -1:
2163 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2164
2165 default:
2166
2/4
✓ Branch 0 taken 31806 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31806 times.
31806 if(it>=0&&it<MAXLEVELS)
2167 {
2168 31806 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2169 }
2170 break;
2171 }
2172 return 0;
2173 }
2174
2175 default:
2176 //it=(1<<(it-1));
2177 /*if (item_type>=itype_max)
2178 {
2179 system_pal();
2180 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2181 game_pal();
2182
2183 return false;
2184 }*/
2185 int32_t itemid = getItemID(itemsbuf, item_type, it);
2186
2187 if(itemid == -1)
2188 return false;
2189
2190 return game->get_item(itemid);
2191 }
2192 26033259 }
2193
2194
2195 80974509 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2196 {
2197
9/9
✓ Branch 0 taken 4763517 times.
✓ Branch 1 taken 42866373 times.
✓ Branch 2 taken 4763517 times.
✓ Branch 3 taken 4763517 times.
✓ Branch 4 taken 4763517 times.
✓ Branch 5 taken 4763517 times.
✓ Branch 6 taken 4763517 times.
✓ Branch 7 taken 4763517 times.
✓ Branch 8 taken 4763517 times.
80974509 switch(item_type)
2198 {
2199 case itype_clock:
2200 {
2201 4763517 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2202
2203
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4763517 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4763517 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2204 return itemsbuf[maxid].fam_type;
2205
2206 4763517 return has_item(itype_clock,1) ? 1 : 0;
2207 }
2208
2209 case itype_key:
2210 4763517 return game->get_keys();
2211
2212 case itype_lkey:
2213 4763517 return game->lvlkeys[get_dlevel()];
2214
2215 case itype_magiccontainer:
2216 4763517 return game->get_maxmagic()/game->get_mp_per_block();
2217
2218 case itype_triforcepiece:
2219 {
2220 4763517 int32_t count=0;
2221
2222
2/2
✓ Branch 0 taken 2438920704 times.
✓ Branch 1 taken 4763517 times.
2443684221 for(int32_t i=0; i<MAXLEVELS; i++)
2223 {
2224 2438920704 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2225 2438920704 }
2226
2227 4763517 return count;
2228 }
2229
2230 case itype_map:
2231 {
2232 4763517 int32_t count=0;
2233
2234
2/2
✓ Branch 0 taken 2438920704 times.
✓ Branch 1 taken 4763517 times.
2443684221 for(int32_t i=0; i<MAXLEVELS; i++)
2235 {
2236 2438920704 count+=(game->lvlitems[i]&liMAP)?1:0;
2237 2438920704 }
2238
2239 4763517 return count;
2240 }
2241
2242 case itype_compass:
2243 {
2244 4763517 int32_t count=0;
2245
2246
2/2
✓ Branch 0 taken 2438920704 times.
✓ Branch 1 taken 4763517 times.
2443684221 for(int32_t i=0; i<MAXLEVELS; i++)
2247 {
2248 2438920704 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2249 2438920704 }
2250
2251 4763517 return count;
2252 }
2253
2254 case itype_bosskey:
2255 {
2256 4763517 int32_t count=0;
2257
2258
2/2
✓ Branch 0 taken 2438920704 times.
✓ Branch 1 taken 4763517 times.
2443684221 for(int32_t i=0; i<MAXLEVELS; i++)
2259 {
2260 2438920704 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2261 2438920704 }
2262
2263 4763517 return count;
2264 }
2265
2266 default:
2267 42866373 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2268
2269
2/2
✓ Branch 0 taken 8091859 times.
✓ Branch 1 taken 34774514 times.
42866373 if(maxid == -1)
2270 34774514 return 0;
2271
2272 8091859 return itemsbuf[maxid].fam_type;
2273 }
2274 80974509 }
2275
2276 74718794 int32_t current_item(int32_t item_type) //item currently being used
2277 {
2278 74718794 return current_item(item_type, true);
2279 }
2280
2281 31 std::map<int32_t, int32_t> itemcache;
2282
2283 // Not actually used by anything at the moment...
2284 void removeFromItemCache(int32_t itemid)
2285 {
2286 itemcache.erase(itemid);
2287 }
2288
2289 22166 void flushItemCache()
2290 {
2291 22166 itemcache.clear();
2292
2293 //also fix the active subscreen if items were deleted -DD
2294
1/2
✓ Branch 0 taken 22166 times.
✗ Branch 1 not taken.
22166 if(game != NULL)
2295 {
2296 22166 verifyBothWeapons();
2297 22166 load_Sitems(&QMisc);
2298 22166 }
2299 22166 }
2300
2301 // This is used often, so it should be as direct as possible.
2302 2654900809 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2303 {
2304
2/2
✓ Branch 0 taken 2599092323 times.
✓ Branch 1 taken 55808486 times.
2654900809 if(jinx_check)
2305 {
2306
4/4
✓ Branch 0 taken 35647284 times.
✓ Branch 1 taken 20161202 times.
✓ Branch 2 taken 32240842 times.
✓ Branch 3 taken 3406442 times.
55808486 if(!(HeroSwordClk() || HeroItemClk()))
2307 32240842 jinx_check = false; //not jinxed
2308 55808486 }
2309
4/4
✓ Branch 0 taken 2632533202 times.
✓ Branch 1 taken 22367607 times.
✓ Branch 2 taken 23398308 times.
✓ Branch 3 taken 2609134894 times.
2654900809 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2310 {
2311 2609134894 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2312
2313
2/2
✓ Branch 0 taken 2597818357 times.
✓ Branch 1 taken 11316537 times.
2609134894 if(res != itemcache.end())
2314 2597818357 return res->second;
2315 11316537 }
2316
2317 57082452 int32_t result = -1;
2318 57082452 int32_t highestlevel = -1;
2319
2320
2/2
✓ Branch 0 taken 14613107712 times.
✓ Branch 1 taken 57082452 times.
14670190164 for(int32_t i=0; i<MAXITEMS; i++)
2321 {
2322
5/6
✓ Branch 0 taken 1152266635 times.
✓ Branch 1 taken 13460841077 times.
✓ Branch 2 taken 17146122 times.
✓ Branch 3 taken 1135120513 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 17146122 times.
14613107712 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2323 {
2324
4/4
✓ Branch 0 taken 5098282 times.
✓ Branch 1 taken 12047840 times.
✓ Branch 2 taken 1326295 times.
✓ Branch 3 taken 15819827 times.
17146122 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2325 {
2326 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2327
2/2
✓ Branch 0 taken 15819671 times.
✓ Branch 1 taken 156 times.
15819827 if(!checkmagiccost(i))
2328 {
2329
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 144 times.
156 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2330 12 }
2331 15819683 }
2332
6/6
✓ Branch 0 taken 14774115 times.
✓ Branch 1 taken 2371863 times.
✓ Branch 2 taken 256688 times.
✓ Branch 3 taken 2115175 times.
✓ Branch 4 taken 1627257 times.
✓ Branch 5 taken 744606 times.
17145978 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2333 {
2334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 744606 times.
744606 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2335 744606 continue;
2336 }
2337
2338
2/2
✓ Branch 0 taken 237664 times.
✓ Branch 1 taken 16163708 times.
16401372 if(itemsbuf[i].fam_type >= highestlevel)
2339 {
2340 16163708 highestlevel = itemsbuf[i].fam_type;
2341 16163708 result=i;
2342 16163708 }
2343 16401372 }
2344 14612362962 }
2345
2346
2/2
✓ Branch 0 taken 23567644 times.
✓ Branch 1 taken 33514808 times.
57082452 if(!jinx_check) //Can't cache jinx_check results
2347 33514808 itemcache[itemtype] = result;
2348 57082452 return result;
2349 2654900809 }
2350
2351 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2352 2631647827 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2353 {
2354 2631647827 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2355
2/2
✓ Branch 0 taken 32555504 times.
✓ Branch 1 taken 2599092323 times.
2631647827 if(!jinx_check) //If not already a jinx-immune-only check...
2356 {
2357 //And the player IS jinxed...
2358
4/4
✓ Branch 0 taken 2579196705 times.
✓ Branch 1 taken 19895618 times.
✓ Branch 2 taken 3357364 times.
✓ Branch 3 taken 2575839341 times.
2599092323 if(HeroSwordClk() || HeroItemClk())
2359 {
2360 //Then do a jinx-immune-only check here
2361 23252982 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2362 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2363 //Should NOT need a compat rule, as this should always return -1 in old quests.
2364
2/2
✓ Branch 0 taken 1102644 times.
✓ Branch 1 taken 22150338 times.
23252982 if(ret2 > -1) return ret2;
2365 22150338 }
2366 2597989679 }
2367 2630545183 return ret;
2368 2631647827 }
2369 16719493 int32_t current_item_power(int32_t itemtype)
2370 {
2371 16719493 int32_t result = current_item_id(itemtype,true);
2372
2/2
✓ Branch 0 taken 12506683 times.
✓ Branch 1 taken 4212810 times.
16719493 return (result<0) ? 0 : itemsbuf[result].power;
2373 }
2374
2375 7 int32_t heart_container_id()
2376 {
2377
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 for(int32_t i=0; i<MAXITEMS; i++)
2378 {
2379
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 196 times.
203 if(itemsbuf[i].family == itype_heartcontainer)
2380 {
2381 7 return i;
2382 }
2383 196 }
2384 return -1;
2385 7 }
2386
2387 4763517 int32_t item_tile_mod()
2388 {
2389 4763517 int32_t tile=0;
2390
2391
2/2
✓ Branch 0 taken 1020710 times.
✓ Branch 1 taken 3742807 times.
4763517 if(game->get_bombs())
2392 {
2393 3742807 int32_t itemid = current_item_id(itype_bomb,false);
2394
3/4
✓ Branch 0 taken 3661748 times.
✓ Branch 1 taken 81059 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3661748 times.
3742807 if(itemid > -1 && checkbunny(itemid))
2395 3661748 tile+=itemsbuf[itemid].ltm;
2396 3742807 }
2397
2398
2/2
✓ Branch 0 taken 3698261 times.
✓ Branch 1 taken 1065256 times.
4763517 if(game->get_sbombs())
2399 {
2400 1065256 int32_t itemid = current_item_id(itype_sbomb,false);
2401
3/4
✓ Branch 0 taken 1063828 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1063828 times.
1065256 if(itemid > -1 && checkbunny(itemid))
2402 1063828 tile+=itemsbuf[itemid].ltm;
2403 1065256 }
2404
2405
2/2
✓ Branch 0 taken 4661760 times.
✓ Branch 1 taken 101757 times.
4763517 if(current_item(itype_clock))
2406 {
2407 101757 int32_t itemid =
2408
1/2
✓ Branch 0 taken 101757 times.
✗ Branch 1 not taken.
101757 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2409 ? iClock
2410 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2411
2/4
✓ Branch 0 taken 101757 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 101757 times.
101757 if(itemid > -1 && checkbunny(itemid))
2412 101757 tile+=itemsbuf[itemid].ltm;
2413 101757 }
2414
2415
2/2
✓ Branch 0 taken 3851797 times.
✓ Branch 1 taken 911720 times.
4763517 if(current_item(itype_key))
2416 {
2417 911720 int32_t itemid =
2418
1/2
✓ Branch 0 taken 911720 times.
✗ Branch 1 not taken.
911720 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2419 ? iKey
2420 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2421
2/4
✓ Branch 0 taken 911720 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 911720 times.
911720 if(itemid > -1 && checkbunny(itemid))
2422 911720 tile+=itemsbuf[itemid].ltm;
2423 911720 }
2424
2425
2/2
✓ Branch 0 taken 4604264 times.
✓ Branch 1 taken 159253 times.
4763517 if(current_item(itype_lkey))
2426 {
2427 159253 int32_t itemid =
2428
2/2
✓ Branch 0 taken 158343 times.
✓ Branch 1 taken 910 times.
159253 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2429 ? iLevelKey
2430 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2431
2/4
✓ Branch 0 taken 159253 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 159253 times.
159253 if(itemid > -1 && checkbunny(itemid))
2432 159253 tile+=itemsbuf[itemid].ltm;
2433 159253 }
2434
2435
2/2
✓ Branch 0 taken 990532 times.
✓ Branch 1 taken 3772985 times.
4763517 if(current_item(itype_map))
2436 {
2437 3772985 int32_t itemid =
2438
2/2
✓ Branch 0 taken 3772199 times.
✓ Branch 1 taken 786 times.
3772985 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2439 ? iMap
2440 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2441
2/4
✓ Branch 0 taken 3772985 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3772985 times.
3772985 if(itemid > -1 && checkbunny(itemid))
2442 3772985 tile+=itemsbuf[itemid].ltm;
2443 3772985 }
2444
2445
2/2
✓ Branch 0 taken 943436 times.
✓ Branch 1 taken 3820081 times.
4763517 if(current_item(itype_compass))
2446 {
2447 3820081 int32_t itemid =
2448
2/2
✓ Branch 0 taken 3739022 times.
✓ Branch 1 taken 81059 times.
3820081 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2449 ? iCompass
2450 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2451
2/4
✓ Branch 0 taken 3820081 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3820081 times.
3820081 if(itemid > -1 && checkbunny(itemid))
2452 3820081 tile+=itemsbuf[itemid].ltm;
2453 3820081 }
2454
2455
2/2
✓ Branch 0 taken 2894313 times.
✓ Branch 1 taken 1869204 times.
4763517 if(current_item(itype_bosskey))
2456 {
2457 1869204 int32_t itemid =
2458
1/2
✓ Branch 0 taken 1869204 times.
✗ Branch 1 not taken.
1869204 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2459 ? iBossKey
2460 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2461
2/4
✓ Branch 0 taken 1869204 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1869204 times.
1869204 if(itemid > -1 && checkbunny(itemid))
2462 1869204 tile+=itemsbuf[itemid].ltm;
2463 1869204 }
2464
2465
2/2
✓ Branch 0 taken 2644325 times.
✓ Branch 1 taken 2119192 times.
4763517 if(current_item(itype_magiccontainer))
2466 {
2467 2119192 int32_t itemid =
2468
2/2
✓ Branch 0 taken 2025977 times.
✓ Branch 1 taken 93215 times.
2119192 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2469 ? iMagicC
2470 93215 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2471
3/4
✓ Branch 0 taken 2119192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 2117322 times.
2119192 if(itemid > -1 && checkbunny(itemid))
2472 2117322 tile+=itemsbuf[itemid].ltm;
2473 2119192 }
2474
2475
2/2
✓ Branch 0 taken 1308959 times.
✓ Branch 1 taken 3454558 times.
4763517 if(current_item(itype_triforcepiece))
2476 {
2477 3454558 int32_t itemid =
2478
1/2
✓ Branch 0 taken 3454558 times.
✗ Branch 1 not taken.
3454558 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2479 ? iTriforce
2480 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2481
2/4
✓ Branch 0 taken 3454558 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3454558 times.
3454558 if(itemid > -1 && checkbunny(itemid))
2482 3454558 tile+=itemsbuf[itemid].ltm;
2483 3454558 }
2484
2485
2/2
✓ Branch 0 taken 4763517 times.
✓ Branch 1 taken 2438920704 times.
2443684221 for(int32_t i=0; i<itype_max; i++)
2486 {
2487
2/2
✓ Branch 0 taken 2382618624 times.
✓ Branch 1 taken 56302080 times.
2438920704 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2488 {
2489
2/2
✓ Branch 0 taken 1099650 times.
✓ Branch 1 taken 55202430 times.
56302080 switch(i)
2490 {
2491 case itype_bomb:
2492 case itype_sbomb:
2493 case itype_clock:
2494 case itype_key:
2495 case itype_lkey:
2496 case itype_map:
2497 case itype_compass:
2498 case itype_bosskey:
2499 case itype_magiccontainer:
2500 case itype_triforcepiece:
2501 1099650 continue; //already handled
2502 }
2503 55202430 }
2504 2437821054 int32_t itemid = current_item_id(i,false);
2505
2/2
✓ Branch 0 taken 2433057537 times.
✓ Branch 1 taken 4763517 times.
2437821054 if(i == itype_shield)
2506 4763517 itemid = getCurrentShield(false);
2507
2508
4/4
✓ Branch 0 taken 67186845 times.
✓ Branch 1 taken 2370634209 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 67085864 times.
2437821054 if(itemid < 0 || !checkbunny(itemid))
2509 2370735190 continue;
2510
2511 67085864 itemdata const& itm = itemsbuf[itemid];
2512
2513
2/2
✓ Branch 0 taken 62899869 times.
✓ Branch 1 taken 4185995 times.
67085864 switch(itm.family)
2514 {
2515 case itype_shield:
2516
1/2
✓ Branch 0 taken 4185995 times.
✗ Branch 1 not taken.
4185995 if(itm.flags & ITEM_FLAG9) //active shield
2517 {
2518 if(!usingActiveShield(itemid))
2519 {
2520 tile+=itm.misc6; //'Inactive PTM'
2521 continue;
2522 }
2523 }
2524 4185995 break;
2525 }
2526
2527 67085864 tile+=itm.ltm;
2528 67085864 }
2529
2530 4763517 return tile;
2531 }
2532
2533 4763517 int32_t bunny_tile_mod()
2534 {
2535
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 4761647 times.
4763517 if(Hero.BunnyClock())
2536 {
2537 1870 return game->get_bunny_ltm();
2538 }
2539 4761647 return 0;
2540 4763517 }
2541
2542 // Hints are drawn on a separate layer to combo reveals.
2543 16332 void draw_lens_under(BITMAP *dest, bool layer)
2544 {
2545 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2546 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2547 //Lens flag 3: Don't show armos/chest/dive items
2548 //Lens flag 4: Show Raft Paths
2549 //Lens flag 5: Show Invisible Enemies
2550
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2551
2552 16332 int32_t strike_hint_table[11]=
2553 {
2554 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2555 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2556 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2557 };
2558
2559 // int32_t page = tmpscr->cpage;
2560 {
2561 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2562 // int32_t temptimer=0;
2563 16332 int32_t tempitem, tempweapon=0;
2564 16332 strike_hint=strike_hint_table[strike_hint_counter];
2565
2566
2/2
✓ Branch 0 taken 15840 times.
✓ Branch 1 taken 492 times.
16332 if(strike_hint_timer>32)
2567 {
2568 492 strike_hint_timer=0;
2569 492 strike_hint_counter=((strike_hint_counter+1)%11);
2570 492 }
2571
2572 16332 ++strike_hint_timer;
2573
2574
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2575 {
2576 2874432 int32_t x = (i & 15) << 4;
2577 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2578 2874432 int32_t tempitemx=-16, tempitemy=-16;
2579 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2580
2581
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2582 {
2583 5748864 int32_t checkflag=0;
2584
2585
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2586 {
2587 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2588 2874432 }
2589 else
2590 {
2591 2874432 checkflag=tmpscr->sflag[i];
2592 }
2593
2594
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2595 {
2596
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2597 {
2598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2599 906 }
2600 else
2601 {
2602 192 checkflag = strike_hint;
2603 }
2604 1098 }
2605
2606
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2607 {
2608 case 0:
2609 case mfZELDA:
2610 case mfPUSHED:
2611 case mfENEMY0:
2612 case mfENEMY1:
2613 case mfENEMY2:
2614 case mfENEMY3:
2615 case mfENEMY4:
2616 case mfENEMY5:
2617 case mfENEMY6:
2618 case mfENEMY7:
2619 case mfENEMY8:
2620 case mfENEMY9:
2621 case mfSINGLE:
2622 case mfSINGLE16:
2623 case mfNOENEMY:
2624 case mfTRAP_H:
2625 case mfTRAP_V:
2626 case mfTRAP_4:
2627 case mfTRAP_LR:
2628 case mfTRAP_UD:
2629 case mfNOGROUNDENEMY:
2630 case mfNOBLOCKS:
2631 case mfSCRIPT1:
2632 case mfSCRIPT2:
2633 case mfSCRIPT3:
2634 case mfSCRIPT4:
2635 case mfSCRIPT5:
2636 case mfSCRIPT6:
2637 case mfSCRIPT7:
2638 case mfSCRIPT8:
2639 case mfSCRIPT9:
2640 case mfSCRIPT10:
2641 case mfSCRIPT11:
2642 case mfSCRIPT12:
2643 case mfSCRIPT13:
2644 case mfSCRIPT14:
2645 case mfSCRIPT15:
2646 case mfSCRIPT16:
2647 case mfSCRIPT17:
2648 case mfSCRIPT18:
2649 case mfSCRIPT19:
2650 case mfSCRIPT20:
2651 case mfPITHOLE:
2652 case mfPITFALLFLOOR:
2653 case mfLAVA:
2654 case mfICE:
2655 case mfICEDAMAGE:
2656 case mfDAMAGE1:
2657 case mfDAMAGE2:
2658 case mfDAMAGE4:
2659 case mfDAMAGE8:
2660 case mfDAMAGE16:
2661 case mfDAMAGE32:
2662 case mfFREEZEALL:
2663 case mfFREZEALLANSFFCS:
2664 case mfFREEZEFFCSOLY:
2665 case mfSCRITPTW1TRIG:
2666 case mfSCRITPTW2TRIG:
2667 case mfSCRITPTW3TRIG:
2668 case mfSCRITPTW4TRIG:
2669 case mfSCRITPTW5TRIG:
2670 case mfSCRITPTW6TRIG:
2671 case mfSCRITPTW7TRIG:
2672 case mfSCRITPTW8TRIG:
2673 case mfSCRITPTW9TRIG:
2674 case mfSCRITPTW10TRIG:
2675 case mfTROWEL:
2676 case mfTROWELNEXT:
2677 case mfTROWELSPECIALITEM:
2678 case mfSLASHPOT:
2679 case mfLIFTPOT:
2680 case mfLIFTORSLASH:
2681 case mfLIFTROCK:
2682 case mfLIFTROCKHEAVY:
2683 case mfDROPITEM:
2684 case mfSPECIALITEM:
2685 case mfDROPKEY:
2686 case mfDROPLKEY:
2687 case mfDROPCOMPASS:
2688 case mfDROPMAP:
2689 case mfDROPBOSSKEY:
2690 case mfSPAWNNPC:
2691 case mfSWITCHHOOK:
2692 case mfSIDEVIEWLADDER:
2693 case mfSIDEVIEWPLATFORM:
2694 case mfNOENEMYSPAWN:
2695 case mfENEMYALL:
2696 case mfNOMIRROR:
2697 case mfUNSAFEGROUND:
2698 case mf168:
2699 case mf169:
2700 case mf170:
2701 case mf171:
2702 case mf172:
2703 case mf173:
2704 case mf174:
2705 case mf175:
2706 case mf176:
2707 case mf177:
2708 case mf178:
2709 case mf179:
2710 case mf180:
2711 case mf181:
2712 case mf182:
2713 case mf183:
2714 case mf184:
2715 case mf185:
2716 case mf186:
2717 case mf187:
2718 case mf188:
2719 case mf189:
2720 case mf190:
2721 case mf191:
2722 case mf192:
2723 case mf193:
2724 case mf194:
2725 case mf195:
2726 case mf196:
2727 case mf197:
2728 case mf198:
2729 case mf199:
2730 case mf200:
2731 case mf201:
2732 case mf202:
2733 case mf203:
2734 case mf204:
2735 case mf205:
2736 case mf206:
2737 case mf207:
2738 case mf208:
2739 case mf209:
2740 case mf210:
2741 case mf211:
2742 case mf212:
2743 case mf213:
2744 case mf214:
2745 case mf215:
2746 case mf216:
2747 case mf217:
2748 case mf218:
2749 case mf219:
2750 case mf220:
2751 case mf221:
2752 case mf222:
2753 case mf223:
2754 case mf224:
2755 case mf225:
2756 case mf226:
2757 case mf227:
2758 case mf228:
2759 case mf229:
2760 case mf230:
2761 case mf231:
2762 case mf232:
2763 case mf233:
2764 case mf234:
2765 case mf235:
2766 case mf236:
2767 case mf237:
2768 case mf238:
2769 case mf239:
2770 case mf240:
2771 case mf241:
2772 case mf242:
2773 case mf243:
2774 case mf244:
2775 case mf245:
2776 case mf246:
2777 case mf247:
2778 case mf248:
2779 case mf249:
2780 case mf250:
2781 case mf251:
2782 case mf252:
2783 case mf253:
2784 case mf254:
2785 case mfEXTENDED:
2786 5706470 break;
2787
2788 case mfPUSHUD:
2789 case mfPUSHLR:
2790 case mfPUSH4:
2791 case mfPUSHU:
2792 case mfPUSHD:
2793 case mfPUSHL:
2794 case mfPUSHR:
2795 case mfPUSHUDNS:
2796 case mfPUSHLRNS:
2797 case mfPUSH4NS:
2798 case mfPUSHUNS:
2799 case mfPUSHDNS:
2800 case mfPUSHLNS:
2801 case mfPUSHRNS:
2802 case mfPUSHUDINS:
2803 case mfPUSHLRINS:
2804 case mfPUSH4INS:
2805 case mfPUSHUINS:
2806 case mfPUSHDINS:
2807 case mfPUSHLINS:
2808 case mfPUSHRINS:
2809
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2810
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2811 {
2812 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2813 }
2814
2815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2816
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2817 {
2818
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2819 {
2820
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2821 {
2822 case cPUSH_HEAVY:
2823 case cPUSH_HW:
2824 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2825 72 tempitemx=x, tempitemy=y;
2826
2827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2828 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2829
2830 72 break;
2831
2832 case cPUSH_HEAVY2:
2833 case cPUSH_HW2:
2834 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2835 63 tempitemx=x, tempitemy=y;
2836
2837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2838 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2839
2840 63 break;
2841 }
2842 1032 }
2843 2438 }
2844
2845 3148 break;
2846
2847 case mfWHISTLE:
2848
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2849 {
2850 tempitem=getItemID(itemsbuf,itype_whistle,1);
2851
2852 if(tempitem<0) break;
2853
2854 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2855 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2856 {
2857 tempitemx=x;
2858 tempitemy=y;
2859 }
2860
2861 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2862 }
2863
2864 2418 break;
2865
2866 //Why is this here?
2867 case mfFAIRY:
2868 case mfMAGICFAIRY:
2869 case mfALLFAIRY:
2870 if(hints)
2871 {
2872 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2873
2874 if(tempitem < 0) break;
2875
2876 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2877 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2878 {
2879 tempitemx=x;
2880 tempitemy=y;
2881 }
2882
2883 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2884 }
2885
2886 break;
2887
2888 case mfANYFIRE:
2889
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2890 {
2891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2892 252 }
2893 else
2894 {
2895 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2896
2897
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2898
2899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2900
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2901 {
2902 189 tempitemx=x;
2903 189 tempitemy=y;
2904 189 }
2905
2906 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2907 }
2908
2909 504 break;
2910
2911 case mfSTRONGFIRE:
2912 if(!hints)
2913 {
2914 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2915 }
2916 else
2917 {
2918 tempitem=getItemID(itemsbuf,itype_candle,2);
2919
2920 if(tempitem<0) break;
2921
2922 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2923 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2924 {
2925 tempitemx=x;
2926 tempitemy=y;
2927 }
2928
2929 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2930 }
2931
2932 break;
2933
2934 case mfMAGICFIRE:
2935 if(!hints)
2936 {
2937 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2938 }
2939 else
2940 {
2941 tempitem=getItemID(itemsbuf,itype_wand,1);
2942
2943 if(tempitem<0) break;
2944
2945 tempweapon=wFire;
2946
2947 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2948 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2949 {
2950 tempitemx=x;
2951 tempitemy=y;
2952 }
2953 else
2954 {
2955 tempweaponx=x;
2956 tempweapony=y;
2957 }
2958
2959 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2960 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2961 }
2962
2963 break;
2964
2965 case mfDIVINEFIRE:
2966 if(!hints)
2967 {
2968 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2969 }
2970 else
2971 {
2972 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2973
2974 if(tempitem<0) break;
2975
2976 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2977 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2978 {
2979 tempitemx=x;
2980 tempitemy=y;
2981 }
2982
2983 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2984 }
2985
2986 break;
2987
2988 case mfARROW:
2989
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2990 {
2991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2992 732 }
2993 else
2994 {
2995 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2996
2997
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2998
2999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3000
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3001 {
3002 61 tempitemx=x;
3003 61 tempitemy=y;
3004 61 }
3005
3006 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3007 }
3008
3009 814 break;
3010
3011 case mfSARROW:
3012 if(!hints)
3013 {
3014 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
3015 }
3016 else
3017 {
3018 tempitem=getItemID(itemsbuf,itype_arrow,2);
3019
3020 if(tempitem<0) break;
3021
3022 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3023 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3024 {
3025 tempitemx=x;
3026 tempitemy=y;
3027 }
3028
3029 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3030 }
3031
3032 break;
3033
3034 case mfGARROW:
3035 if(!hints)
3036 {
3037 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
3038 }
3039 else
3040 {
3041 tempitem=getItemID(itemsbuf,itype_arrow,3);
3042
3043 if(tempitem<0) break;
3044
3045 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3046 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3047 {
3048 tempitemx=x;
3049 tempitemy=y;
3050 }
3051
3052 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3053 }
3054
3055 break;
3056
3057 case mfBOMB:
3058
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3059 {
3060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3061 16 }
3062 else
3063 {
3064 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3065 17 tempweapon = wLitBomb;
3066
3067 //if (tempitem<0) break;
3068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3069
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3070 {
3071 12 tempweaponx=x;
3072 12 tempweapony=y;
3073 12 }
3074
3075 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3076 }
3077
3078 33 break;
3079
3080 case mfSBOMB:
3081
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3082 {
3083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3084 48 }
3085 else
3086 {
3087 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3088 //if (tempitem<0) break;
3089 48 tempweapon = wLitSBomb;
3090
3091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3092
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3093 {
3094 36 tempweaponx=x;
3095 36 tempweapony=y;
3096 36 }
3097
3098 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3099 }
3100
3101 96 break;
3102
3103 case mfARMOS_SECRET:
3104
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3105 {
3106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3107 12 }
3108 24 break;
3109
3110 case mfBRANG:
3111
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3112 {
3113 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3114 }
3115 else
3116 {
3117 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3118
3119
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3120
3121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3122
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3123 {
3124 4 tempitemx=x;
3125 4 tempitemy=y;
3126 4 }
3127
3128 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3129 }
3130
3131 5 break;
3132
3133 case mfMBRANG:
3134 if(!hints)
3135 {
3136 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3137 }
3138 else
3139 {
3140 tempitem=getItemID(itemsbuf,itype_brang,2);
3141
3142 if(tempitem<0) break;
3143
3144 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3145 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3146 {
3147 tempitemx=x;
3148 tempitemy=y;
3149 }
3150
3151 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3152 }
3153
3154 break;
3155
3156 case mfFBRANG:
3157 if(!hints)
3158 {
3159 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3160 }
3161 else
3162 {
3163 tempitem=getItemID(itemsbuf,itype_brang,3);
3164
3165 if(tempitem<0) break;
3166
3167 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3168 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3169 {
3170 tempitemx=x;
3171 tempitemy=y;
3172 }
3173
3174 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3175 }
3176
3177 break;
3178
3179 case mfWANDMAGIC:
3180 if(!hints)
3181 {
3182 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3183 }
3184 else
3185 {
3186 tempitem=getItemID(itemsbuf,itype_wand,1);
3187
3188 if(tempitem<0) break;
3189
3190 tempweapon=itemsbuf[tempitem].wpn3;
3191
3192 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3193 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3194 {
3195 tempitemx=x;
3196 tempitemy=y;
3197 }
3198 else
3199 {
3200 tempweaponx=x;
3201 tempweapony=y;
3202 --lens_hint_weapon[wMagic][4];
3203
3204 if(lens_hint_weapon[wMagic][4]<-8)
3205 {
3206 lens_hint_weapon[wMagic][4]=8;
3207 }
3208 }
3209
3210 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3211 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3212 }
3213
3214 break;
3215
3216 case mfREFMAGIC:
3217
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3218 {
3219 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3220 }
3221 else
3222 {
3223 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3224
3225
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3226
3227 16 tempweapon=ewMagic;
3228
3229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3230
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3231 {
3232 13 tempitemx=x;
3233 13 tempitemy=y;
3234 13 }
3235 else
3236 {
3237 3 tempweaponx=x;
3238 3 tempweapony=y;
3239
3240
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3241 {
3242 1 --lens_hint_weapon[ewMagic][4];
3243 1 }
3244 else
3245 {
3246 2 ++lens_hint_weapon[ewMagic][4];
3247 }
3248
3249
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3250 {
3251 lens_hint_weapon[ewMagic][2]=up;
3252 }
3253
3254
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3255 {
3256 2 lens_hint_weapon[ewMagic][2]=down;
3257 2 }
3258 }
3259
3260 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3261 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3262 }
3263
3264 16 break;
3265
3266 case mfREFFIREBALL:
3267
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3268 {
3269 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3270 }
3271 else
3272 {
3273 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3274
3275
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3276
3277 16 tempweapon=ewFireball;
3278
3279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3280
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3281 {
3282 12 tempitemx=x;
3283 12 tempitemy=y;
3284 12 tempweaponx=x;
3285 12 tempweapony=y;
3286 12 ++lens_hint_weapon[ewFireball][3];
3287
3288
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3289 {
3290 1 lens_hint_weapon[ewFireball][3]=-8;
3291 1 lens_hint_weapon[ewFireball][4]=8;
3292 1 }
3293
3294
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3295 {
3296 8 ++lens_hint_weapon[ewFireball][4];
3297 8 }
3298 else
3299 {
3300 4 --lens_hint_weapon[ewFireball][4];
3301 }
3302 12 }
3303
3304 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3305 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3306 }
3307
3308 16 break;
3309
3310 case mfSWORD:
3311
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3312 {
3313 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3314 }
3315 else
3316 {
3317 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3318
3319
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3320
3321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3322
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3323 {
3324 5 tempitemx=x;
3325 5 tempitemy=y;
3326 5 }
3327
3328 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3329 }
3330
3331 7 break;
3332
3333 case mfWSWORD:
3334 if(!hints)
3335 {
3336 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3337 }
3338 else
3339 {
3340 tempitem=getItemID(itemsbuf,itype_sword,2);
3341
3342 if(tempitem<0) break;
3343
3344 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3345 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3346 {
3347 tempitemx=x;
3348 tempitemy=y;
3349 }
3350
3351 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3352 }
3353
3354 break;
3355
3356 case mfMSWORD:
3357 if(!hints)
3358 {
3359 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3360 }
3361 else
3362 {
3363 tempitem=getItemID(itemsbuf,itype_sword,3);
3364
3365 if(tempitem<0) break;
3366
3367 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3368 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3369 {
3370 tempitemx=x;
3371 tempitemy=y;
3372 }
3373
3374 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3375 }
3376
3377 break;
3378
3379 case mfXSWORD:
3380 if(!hints)
3381 {
3382 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3383 }
3384 else
3385 {
3386 tempitem=getItemID(itemsbuf,itype_sword,4);
3387
3388 if(tempitem<0) break;
3389
3390 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3391 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3392 {
3393 tempitemx=x;
3394 tempitemy=y;
3395 }
3396
3397 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3398 }
3399
3400 break;
3401
3402 case mfSWORDBEAM:
3403
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3404 {
3405 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3406 }
3407 else
3408 {
3409 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3410
3411
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3412
3413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3414
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3415 {
3416 11 tempitemx=x;
3417 11 tempitemy=y;
3418 11 }
3419
3420 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3421 }
3422
3423 16 break;
3424
3425 case mfWSWORDBEAM:
3426 if(!hints)
3427 {
3428 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3429 }
3430 else
3431 {
3432 tempitem=getItemID(itemsbuf,itype_sword,2);
3433
3434 if(tempitem<0) break;
3435
3436 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3437 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3438 {
3439 tempitemx=x;
3440 tempitemy=y;
3441 }
3442
3443 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3444 }
3445
3446 break;
3447
3448 case mfMSWORDBEAM:
3449 if(!hints)
3450 {
3451 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3452 }
3453 else
3454 {
3455 tempitem=getItemID(itemsbuf,itype_sword,3);
3456
3457 if(tempitem<0) break;
3458
3459 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3460 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3461 {
3462 tempitemx=x;
3463 tempitemy=y;
3464 }
3465
3466 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3467 }
3468
3469 break;
3470
3471 case mfXSWORDBEAM:
3472 if(!hints)
3473 {
3474 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3475 }
3476 else
3477 {
3478 tempitem=getItemID(itemsbuf,itype_sword,4);
3479
3480 if(tempitem<0) break;
3481
3482 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3483 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3484 {
3485 tempitemx=x;
3486 tempitemy=y;
3487 }
3488
3489 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3490 }
3491
3492 break;
3493
3494 case mfHOOKSHOT:
3495
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3496 {
3497 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3498 }
3499 else
3500 {
3501 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3502
3503
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3504
3505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3506
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3507 {
3508 12 tempitemx=x;
3509 12 tempitemy=y;
3510 12 }
3511
3512 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3513 }
3514
3515 17 break;
3516
3517 case mfWAND:
3518
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3519 {
3520 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3521 }
3522 else
3523 {
3524 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3525
3526
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3527
3528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3529
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3530 {
3531 28 tempitemx=x;
3532 28 tempitemy=y;
3533 28 }
3534
3535 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3536 }
3537
3538 35 break;
3539
3540 case mfHAMMER:
3541
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3542 {
3543 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3544 }
3545 else
3546 {
3547 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3548
3549
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3550
3551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3552
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3553 {
3554 13 tempitemx=x;
3555 13 tempitemy=y;
3556 13 }
3557
3558 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3559 }
3560
3561 17 break;
3562
3563 case mfARMOS_ITEM:
3564 case mfDIVE_ITEM:
3565
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3566 {
3567 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3568 2064 }
3569 2064 break;
3570
3571 case 16:
3572 case 17:
3573 case 18:
3574 case 19:
3575 case 20:
3576 case 21:
3577 case 22:
3578 case 23:
3579 case 24:
3580 case 25:
3581 case 26:
3582 case 27:
3583 case 28:
3584 case 29:
3585 case 30:
3586 case 31:
3587
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3589 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3590
3591 3618 break;
3592 case mfSECRETSNEXT:
3593 if(!hints)
3594 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3595 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3596
3597 break;
3598
3599 case mfSTRIKE:
3600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3601 {
3602 906 goto special;
3603 }
3604 else
3605 {
3606 break;
3607 }
3608
3609 28640 default: goto special;
3610
3611 special:
3612
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3613 {
3614
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3615 {
3616 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3617 4913 }
3618 6549 }
3619
3620 29546 break;
3621 }
3622 5748864 }
3623 2874432 }
3624
3625
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3626 {
3627
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3628 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3629
3630
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3631 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3632
3633
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3634 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3635
3636
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3637 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3638
3639
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3640 {
3641 43 showbombeddoor(dest, 0);
3642 43 }
3643
3644
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3645 {
3646 39 showbombeddoor(dest, 1);
3647 39 }
3648
3649
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3650 {
3651 showbombeddoor(dest, 2);
3652 }
3653
3654
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3655 {
3656 37 showbombeddoor(dest, 3);
3657 37 }
3658 8166 }
3659
3660
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3661 {
3662
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3663 {
3664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3665 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3666 1123 }
3667 else
3668 {
3669
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3670 {
3671 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3672 48 int32_t tempitemx=-16;
3673 48 int32_t tempitemy=-16;
3674
3675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3676
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3677 {
3678 24 tempitemx=tmpscr->stairx;
3679 24 tempitemy=tmpscr->stairy+playing_field_offset;
3680 24 }
3681
3682 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3683 48 }
3684 }
3685 2034 }
3686 }
3687 16332 }
3688
3689 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3690
3691 7997 void draw_lens_over()
3692 {
3693 // Oh, what the heck.
3694 static BITMAP *lens_scr = NULL;
3695 static int32_t last_width = -1;
3696 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3697
3698 // Only redraw the circle if the size has changed
3699
2/2
✓ Branch 0 taken 7992 times.
✓ Branch 1 taken 5 times.
7997 if(width != last_width)
3700 {
3701
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(lens_scr == NULL)
3702 {
3703 5 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3704 5 }
3705
3706 5 clear_to_color(lens_scr, BLACK);
3707 5 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3708 5 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3709 5 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3710 5 last_width=width;
3711 5 }
3712
3713 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3714 7997 }
3715
3716 //----------------------------------------------------------------
3717
3718 30701 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3719 {
3720 //recreating a big bitmap every frame is highly sluggish.
3721
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 30699 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
30701 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3722 30701 clear_to_color(wavebuf, BLACK);
3723 30701 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3724
3725 int32_t ofs;
3726 // int32_t amplitude=8;
3727 // int32_t wavelength=4;
3728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30701 times.
30701 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3729
3/6
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3730 30701 int32_t amp2=168;
3731
2/4
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3732 30701 int32_t i=frame%amp2;
3733
3734
2/2
✓ Branch 0 taken 5157768 times.
✓ Branch 1 taken 30701 times.
5188469 for(int32_t j=0; j<168; j++)
3735 {
3736
3/4
✓ Branch 0 taken 2578884 times.
✓ Branch 1 taken 2578884 times.
✓ Branch 2 taken 2578884 times.
✗ Branch 3 not taken.
5157768 if(j&1 && interpol)
3737 {
3738 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3739 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3740 }
3741 else
3742 {
3743 5157768 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3744 }
3745
3746
1/2
✓ Branch 0 taken 5157768 times.
✗ Branch 1 not taken.
5157768 if(ofs)
3747 {
3748
2/2
✓ Branch 0 taken 1320388608 times.
✓ Branch 1 taken 5157768 times.
1325546376 for(int32_t k=0; k<256; k++)
3749 {
3750 1320388608 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3751 1320388608 }
3752 5157768 }
3753 5157768 }
3754 30701 }
3755
3756 3312 void draw_fuzzy(int32_t fuzz)
3757 // draws from right half of scrollbuf to framebuf
3758 {
3759 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3760 byte *start, *si, *di;
3761
3762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3312 times.
3312 if(fuzz<1)
3763 fuzz = 1;
3764
3765 3312 xstep = 128%fuzz;
3766
3767
2/2
✓ Branch 0 taken 690 times.
✓ Branch 1 taken 2622 times.
3312 if(xstep > 0)
3768 2622 xstep = fuzz-xstep;
3769
3770 3312 ystep = 112%fuzz;
3771
3772
2/2
✓ Branch 0 taken 966 times.
✓ Branch 1 taken 2346 times.
3312 if(ystep > 0)
3773 2346 ystep = fuzz-ystep;
3774
3775 3312 firsty = 1;
3776
3777
2/2
✓ Branch 0 taken 3312 times.
✓ Branch 1 taken 119508 times.
122820 for(y=0; y<224;)
3778 {
3779 119508 start = &(scrollbuf->line[y][256]);
3780
3781
4/4
✓ Branch 0 taken 117852 times.
✓ Branch 1 taken 743544 times.
✓ Branch 2 taken 741888 times.
✓ Branch 3 taken 119508 times.
861396 for(dy=0; dy<ystep && dy+y<224; dy++)
3782 {
3783 741888 si = start;
3784 741888 di = &(framebuf->line[y+dy][0]);
3785 741888 i = xstep;
3786 741888 firstx = 1;
3787
3788
2/2
✓ Branch 0 taken 189923328 times.
✓ Branch 1 taken 741888 times.
190665216 for(dx=0; dx<256; dx++)
3789 {
3790 189923328 *(di++) = *si;
3791
3792
2/2
✓ Branch 0 taken 160031424 times.
✓ Branch 1 taken 29891904 times.
189923328 if(++i >= fuzz)
3793 {
3794
2/2
✓ Branch 0 taken 29150016 times.
✓ Branch 1 taken 741888 times.
29891904 if(!firstx)
3795 29150016 si += fuzz;
3796 else
3797 {
3798 741888 si += fuzz-xstep;
3799 741888 firstx = 0;
3800 }
3801
3802 29891904 i = 0;
3803 29891904 }
3804 189923328 }
3805 741888 }
3806
3807
2/2
✓ Branch 0 taken 116196 times.
✓ Branch 1 taken 3312 times.
119508 if(!firsty)
3808 116196 y += fuzz;
3809 else
3810 {
3811 3312 y += ystep;
3812 3312 ystep = fuzz;
3813 3312 firsty = 0;
3814 }
3815 }
3816 3312 }
3817
3818 7521922 void updatescr(bool allowwavy)
3819 {
3820
4/6
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 7521891 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31 times.
✓ Branch 4 taken 31 times.
✗ Branch 5 not taken.
7521922 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3821
4/6
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 7521891 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 31 times.
7521922 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3822
3823
2/2
✓ Branch 0 taken 7496218 times.
✓ Branch 1 taken 25704 times.
7521922 if(toogam)
3824 {
3825 25704 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3826 25704 }
3827
3828
1/2
✓ Branch 0 taken 7521922 times.
✗ Branch 1 not taken.
7521922 if(Showpal)
3829 dump_pal(framebuf);
3830
3831
2/2
✓ Branch 0 taken 7427458 times.
✓ Branch 1 taken 94464 times.
7521922 if(!Playing)
3832 94464 black_opening_count=0;
3833
3834
2/2
✓ Branch 0 taken 7475524 times.
✓ Branch 1 taken 46398 times.
7521922 if(black_opening_count<0) //shape is opening up
3835 {
3836 46398 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3837
3838
2/4
✓ Branch 0 taken 46398 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 46398 times.
46398 if(Advance||(!Paused))
3839 {
3840 46398 ++black_opening_count;
3841 46398 }
3842 46398 }
3843
2/2
✓ Branch 0 taken 7457308 times.
✓ Branch 1 taken 18216 times.
7475524 else if(black_opening_count>0) //shape is closing
3844 {
3845 18216 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3846
3847
2/4
✓ Branch 0 taken 18216 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18216 times.
18216 if(Advance||(!Paused))
3848 {
3849 18216 --black_opening_count;
3850 18216 }
3851 18216 }
3852
3853
3/4
✓ Branch 0 taken 7458287 times.
✓ Branch 1 taken 63635 times.
✓ Branch 2 taken 7458287 times.
✗ Branch 3 not taken.
7521922 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3854 {
3855 black_opening_shape = bosCIRCLE;
3856 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3857 refreshTints();
3858 refreshpal=true;
3859 }
3860
3861
2/2
✓ Branch 0 taken 7306228 times.
✓ Branch 1 taken 215694 times.
7521922 if(refreshpal)
3862 {
3863 215694 refreshpal=false;
3864 215694 RAMpal[253] = _RGB(0,0,0);
3865 215694 RAMpal[254] = _RGB(63,63,63);
3866 215694 hw_palette = &RAMpal;
3867 215694 update_hw_pal = true;
3868
3869 215694 create_rgb_table(&rgb_table, RAMpal, NULL);
3870 215694 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3871 215694 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3872
3873
2/2
✓ Branch 0 taken 55217664 times.
✓ Branch 1 taken 215694 times.
55433358 for(int32_t q=0; q<PAL_SIZE; q++)
3874 {
3875 55217664 trans_table2.data[0][q] = q;
3876 55217664 trans_table2.data[q][q] = q;
3877 55217664 }
3878 215694 }
3879
3880 7521922 bool clearwavy = (wavy <= 0);
3881
3882
2/2
✓ Branch 0 taken 7245 times.
✓ Branch 1 taken 7514677 times.
7521922 if(wavy <= 0)
3883 {
3884 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3885 7514677 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3886 7514677 }
3887
3888 7521922 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3889
3890
6/6
✓ Branch 0 taken 30951 times.
✓ Branch 1 taken 7490971 times.
✓ Branch 2 taken 30829 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 30701 times.
7521922 if(wavy && Playing && allowwavy)
3891 {
3892 30701 draw_wavy(framebuf, wavybuf, wavy,false);
3893 30701 }
3894
3895
2/2
✓ Branch 0 taken 7514677 times.
✓ Branch 1 taken 7245 times.
7521922 if(clearwavy)
3896 7514677 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3897
2/4
✓ Branch 0 taken 7245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7245 times.
7245 else if(Playing && !Paused)
3898 7245 wavy--; // Wavy was set by a script. Decrement it.
3899
3900
5/6
✓ Branch 0 taken 7427458 times.
✓ Branch 1 taken 94464 times.
✓ Branch 2 taken 170662 times.
✓ Branch 3 taken 7256796 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 170662 times.
7521922 if(Playing && msgpos && !screenscrolling)
3901 {
3902
1/2
✓ Branch 0 taken 170662 times.
✗ Branch 1 not taken.
170662 if(!(msg_bg_display_buf->clip))
3903 170662 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3904
1/2
✓ Branch 0 taken 170662 times.
✗ Branch 1 not taken.
170662 if(!(msg_portrait_display_buf->clip))
3905 170662 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3906
1/2
✓ Branch 0 taken 170662 times.
✗ Branch 1 not taken.
170662 if(!(msg_txt_display_buf->clip))
3907 170662 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3908 170662 }
3909
3910 /*
3911 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3912 {
3913 BITMAP* subBmp = 0;
3914 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3915 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3916 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3917 destroy_bitmap(subBmp);
3918 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3919 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3920 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3921 }
3922 */
3923
3924
2/2
✓ Branch 0 taken 7489601 times.
✓ Branch 1 taken 32321 times.
7521922 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3925
3926
2/2
✓ Branch 0 taken 7489601 times.
✓ Branch 1 taken 32321 times.
7521922 if(nosubscr)
3927 {
3928 32321 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3929 32321 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3930 32321 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3931 32321 }
3932
3933 //TODO: Optimize blit 'overcalls' -Gleeok
3934
2/2
✓ Branch 0 taken 32321 times.
✓ Branch 1 taken 7489601 times.
7521922 BITMAP *source = nosubscr ? panorama : wavybuf;
3935 7521922 blit(source,framebuf,0,0,0,0,256,224);
3936
3937 7521922 update_hw_screen();
3938 7521922 }
3939
3940 //----------------------------------------------------------------
3941
3942 PALETTE sys_pal;
3943
3944 int32_t onGUISnapshot()
3945 {
3946 char buf[200];
3947 int32_t num=0;
3948 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3949 do
3950 {
3951 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3952 }
3953 while(num<99999 && exists(buf));
3954
3955 BITMAP *b = create_bitmap_ex(8,resx,resy);
3956
3957 if(b)
3958 {
3959 if(MenuOpen)
3960 {
3961 //Cannot load game's palette while GUI elements are in focus. -Z
3962 //If there is a way to do this, then I have missed it.
3963 /*
3964 game_pal();
3965 RAMpal[253] = _RGB(0,0,0);
3966 RAMpal[254] = _RGB(63,63,63);
3967 zc_set_palette_range(RAMpal,0,255,false);
3968 memcpy(RAMpal, snappal, sizeof(snappal));
3969 create_rgb_table(&rgb_table, RAMpal, NULL);
3970 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3971 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3972
3973 for(int32_t q=0; q<PAL_SIZE; q++)
3974 {
3975 trans_table2.data[0][q] = q;
3976 trans_table2.data[q][q] = q;
3977 }
3978 */
3979 //ringcolor(false);
3980 //get_palette(RAMpal);
3981 blit(screen,b,0,0,0,0,resx,resy);
3982 //al_trace("Menu Open\n");
3983 //game_pal();
3984 //PALETTE temppal;
3985 //get_palette(temppal);
3986 //system_pal();
3987 save_bitmap(buf,b,sys_pal);
3988 //save_bitmap(buf,b,RAMpal);
3989 //save_bitmap(buf,b,snappal);
3990 }
3991 else
3992 {
3993 blit(screen,b,0,0,0,0,resx,resy);
3994 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
3995 }
3996 destroy_bitmap(b);
3997 }
3998
3999 return D_O_K;
4000 }
4001
4002 int32_t onNonGUISnapshot()
4003 {
4004 PALETTE temppal;
4005 get_palette(temppal);
4006 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
4007
4008 char buf[200];
4009 int32_t num=0;
4010
4011 do
4012 {
4013 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
4014 }
4015 while(num<99999 && exists(buf));
4016
4017 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
4018
4019 return D_O_K;
4020 }
4021
4022 int32_t onSnapshot()
4023 {
4024 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
4025 {
4026 onGUISnapshot();
4027 }
4028 else
4029 {
4030 onNonGUISnapshot();
4031 }
4032
4033 return D_O_K;
4034 }
4035
4036 int32_t onSaveMapPic()
4037 {
4038 int32_t mapres2 = 0;
4039 char buf[200];
4040 int32_t num=0;
4041 mapscr tmpscr_b[2];
4042 mapscr tmpscr_c[6];
4043 BITMAP* _screen_draw_buffer = NULL;
4044 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4045 set_clip_state(_screen_draw_buffer,1);
4046
4047 for(int32_t i=0; i<6; ++i)
4048 {
4049 tmpscr_c[i] = tmpscr2[i];
4050 tmpscr2[i].zero_memory();
4051
4052 if(i>=2)
4053 {
4054 continue;
4055 }
4056
4057 tmpscr_b[i] = tmpscr[i];
4058 tmpscr[i].zero_memory();
4059 }
4060
4061 do
4062 {
4063 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4064 }
4065 while(num<99999 && exists(buf));
4066
4067 BITMAP* mappic = NULL;
4068
4069
4070 bool done=false, redraw=true;
4071
4072 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4073
4074 if(!mappic)
4075 {
4076 system_pal();
4077 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4078 game_pal();
4079 return D_O_K;;
4080 }
4081
4082 // draw the map
4083 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4084
4085 for(int32_t y=0; y<8; y++)
4086 {
4087 for(int32_t x=0; x<16; x++)
4088 {
4089 if(!displayOnMap(x, y))
4090 {
4091 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4092 }
4093 else
4094 {
4095 int32_t s = (y<<4) + x;
4096 loadscr2(1,s,-1);
4097
4098 for(int32_t i=0; i<6; i++)
4099 {
4100 if(tmpscr[1].layermap[i]<=0)
4101 continue;
4102
4103 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4104 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4105 {
4106 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4107
4108 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4109 }
4110 }
4111
4112 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4113
4114 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4115
4116 putscr(_screen_draw_buffer,256,0,tmpscr+1);
4117 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4118
4119 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4120
4121 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4122 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4123 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
4124 {
4125 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4126 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4127 }
4128 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4129
4130 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4131
4132 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4133 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4134 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4135 {
4136 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4137 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4138 }
4139 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4140 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4141
4142 }
4143
4144 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4145 }
4146 }
4147
4148 for(int32_t i=0; i<6; ++i)
4149 {
4150 tmpscr2[i]=tmpscr_c[i];
4151
4152 if(i>=2)
4153 {
4154 continue;
4155 }
4156
4157 tmpscr[i]=tmpscr_b[i];
4158 }
4159
4160 save_bitmap(buf,mappic,RAMpal);
4161 destroy_bitmap(mappic);
4162 destroy_bitmap(_screen_draw_buffer);
4163 return D_O_K;
4164 }
4165
4166 /*
4167 int32_t onSaveMapPic()
4168 {
4169 BITMAP* mappic = NULL;
4170 BITMAP* _screen_draw_buffer = NULL;
4171 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4172 int32_t mapres2 = 0;
4173 char buf[20];
4174 int32_t num=0;
4175 set_clip_state(_screen_draw_buffer,1);
4176 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4177
4178 do
4179 {
4180 sprintf(buf, "zelda%03d.png", ++num);
4181 }
4182 while(num<999 && exists(buf));
4183
4184 // if(!mappic) {
4185 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4186
4187 if(!mappic)
4188 {
4189 system_pal();
4190 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4191 game_pal();
4192 return D_O_K;
4193 }
4194
4195 // }
4196
4197 int32_t layermap, layerscreen;
4198 int32_t x2=0;
4199
4200 // draw the map
4201 for(int32_t y=0; y<8; y++)
4202 {
4203 for(int32_t x=0; x<16; x++)
4204 {
4205 int32_t s = (y<<4) + x;
4206
4207 if(!displayOnMap(x, y))
4208 {
4209 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4210 }
4211 else
4212 {
4213 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4214 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4215
4216 for(int32_t k=0; k<4; k++)
4217 {
4218 if(k==2)
4219 {
4220 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4221 }
4222
4223 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4224
4225 if(layermap>-1)
4226 {
4227 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4228
4229 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4230 {
4231 for(int32_t i=0; i<176; i++)
4232 {
4233 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4234 }
4235 }
4236 else
4237 {
4238 for(int32_t i=0; i<176; i++)
4239 {
4240 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4241 }
4242 }
4243 }
4244 }
4245
4246 for(int32_t i=0; i<176; i++)
4247 {
4248 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4249 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4250 {
4251 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4252 }
4253 }
4254
4255 for(int32_t k=4; k<6; k++)
4256 {
4257 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4258
4259 if(layermap>-1)
4260 {
4261 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4262
4263 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4264 {
4265 for(int32_t i=0; i<176; i++)
4266 {
4267 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4268 }
4269 }
4270 else
4271 {
4272 for(int32_t i=0; i<176; i++)
4273 {
4274 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4275 }
4276 }
4277 }
4278 }
4279 }
4280
4281 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4282 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4283 }
4284
4285 }
4286
4287 save_bitmap(buf,mappic,RAMpal);
4288 destroy_bitmap(mappic);
4289 destroy_bitmap(_screen_draw_buffer);
4290 return D_O_K;
4291 }
4292 */
4293
4294 14 void f_Quit(int32_t type)
4295 {
4296
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4297 return;
4298
4299 14 bool from_menu = is_sys_pal;
4300
4301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4302 {
4303 14 music_pause();
4304 14 pause_all_sfx();
4305 14 sys_mouse();
4306 14 }
4307 14 enter_sys_pal();
4308 14 clear_keybuf();
4309
4310
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if (replay_is_active() && replay_get_version() <= 9)
4311 14 replay_poll();
4312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4313 14 replay_peek_quit();
4314
4315
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4316 switch(type)
4317 {
4318 case qQUIT:
4319 onQuit();
4320 break;
4321
4322 case qRESET:
4323 onReset();
4324 break;
4325
4326 case qEXIT:
4327 onExit();
4328 break;
4329 }
4330
4331
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4332 {
4333 14 kill_sfx();
4334 14 music_stop();
4335 14 exit_sys_pal();
4336 14 update_hw_screen();
4337 14 }
4338 else
4339 {
4340 exit_sys_pal();
4341 if(!from_menu)
4342 {
4343 music_resume();
4344 resume_all_sfx();
4345 }
4346 }
4347
4348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4349 14 game_mouse();
4350 14 eat_buttons();
4351
4352 14 zc_readrawkey(KEY_ESC);
4353
4354 14 zc_readrawkey(KEY_ENTER);
4355 14 }
4356
4357 //----------------------------------------------------------------
4358
4359 int32_t onNoWalls()
4360 {
4361 cheats_enqueue(Cheat::Walls);
4362 return D_O_K;
4363 }
4364
4365 int32_t onIgnoreSideview()
4366 {
4367 cheats_enqueue(Cheat::IgnoreSideView);
4368 return D_O_K;
4369 }
4370
4371 7521864 int32_t input_idle(bool checkmouse)
4372 {
4373 static int32_t mx, my, mz, mb;
4374
4375
4/6
✓ Branch 0 taken 7521864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1928083 times.
✓ Branch 3 taken 5593781 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1928083 times.
9449947 if(keypressed() || zc_key_pressed() ||
4376
4/8
✓ Branch 0 taken 1928083 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1928083 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1928083 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1928083 times.
✗ Branch 7 not taken.
1928083 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4377 {
4378 5593781 idle_count = 0;
4379
4380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5593781 times.
5593781 if(active_count < MAX_ACTIVE)
4381 {
4382 5593781 ++active_count;
4383 5593781 }
4384 5593781 }
4385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1928083 times.
1928083 else if(idle_count < MAX_IDLE)
4386 {
4387 1928083 ++idle_count;
4388 1928083 active_count = 0;
4389 1928083 }
4390
4391 7521864 mx = mouse_x;
4392 7521864 my = mouse_y;
4393 7521864 mz = mouse_z;
4394 7521864 mb = mouse_b;
4395
4396 7521864 return idle_count;
4397 }
4398
4399 int32_t onGoFast()
4400 {
4401 cheats_enqueue(Cheat::Fast);
4402 return D_O_K;
4403 }
4404
4405 int32_t onKillCheat()
4406 {
4407 cheats_enqueue(Cheat::Kill);
4408 return D_O_K;
4409 }
4410
4411 int32_t onSecretsCheat()
4412 {
4413 cheats_enqueue(Cheat::TrigSecrets);
4414 return D_O_K;
4415 }
4416 int32_t onSecretsCheatPerm()
4417 {
4418 cheats_enqueue(Cheat::TrigSecretsPerm);
4419 return D_O_K;
4420 }
4421
4422 int32_t onShowLayer0()
4423 {
4424 show_layer_0 = !show_layer_0;
4425 return D_O_K;
4426 }
4427 int32_t onShowLayer1()
4428 {
4429 show_layer_1 = !show_layer_1;
4430 return D_O_K;
4431 }
4432 int32_t onShowLayer2()
4433 {
4434 show_layer_2 = !show_layer_2;
4435 return D_O_K;
4436 }
4437 int32_t onShowLayer3()
4438 {
4439 show_layer_3 = !show_layer_3;
4440 return D_O_K;
4441 }
4442 int32_t onShowLayer4()
4443 {
4444 show_layer_4 = !show_layer_4;
4445 return D_O_K;
4446 }
4447 int32_t onShowLayer5()
4448 {
4449 show_layer_5 = !show_layer_5;
4450 return D_O_K;
4451 }
4452 int32_t onShowLayer6()
4453 {
4454 show_layer_6 = !show_layer_6;
4455 return D_O_K;
4456 }
4457 int32_t onShowLayerO()
4458 {
4459 show_layer_over=!show_layer_over;
4460 return D_O_K;
4461 }
4462 int32_t onShowLayerP()
4463 {
4464 show_layer_push=!show_layer_push;
4465 return D_O_K;
4466 }
4467 int32_t onShowLayerS()
4468 {
4469 show_sprites=!show_sprites;
4470 return D_O_K;
4471 }
4472 int32_t onShowLayerF()
4473 {
4474 show_ffcs=!show_ffcs;
4475 return D_O_K;
4476 }
4477 int32_t onShowLayerW()
4478 {
4479 show_walkflags=!show_walkflags;
4480 if(show_walkflags)
4481 show_effectflags = false;
4482 return D_O_K;
4483 }
4484 int32_t onShowLayerE()
4485 {
4486 show_effectflags=!show_effectflags;
4487 if(show_effectflags)
4488 show_walkflags = false;
4489 return D_O_K;
4490 }
4491 int32_t onShowFFScripts()
4492 {
4493 show_ff_scripts=!show_ff_scripts;
4494 return D_O_K;
4495 }
4496 int32_t onShowHitboxes()
4497 {
4498 show_hitboxes=!show_hitboxes;
4499 return D_O_K;
4500 }
4501 int32_t onShowInfoOpacity()
4502 {
4503 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4504 zc_set_config("zc","debug_info_opacity",info_opacity);
4505 return D_O_K;
4506 }
4507
4508 int32_t onLightSwitch()
4509 {
4510 cheats_enqueue(Cheat::Light);
4511 return D_O_K;
4512 }
4513
4514 int32_t onGoTo();
4515 int32_t onGoToComplete();
4516
4517 7521864 void syskeys()
4518 {
4519 7521864 update_system_keys();
4520
4521 int32_t oldtitle_version;
4522
4523
1/2
✓ Branch 0 taken 7521864 times.
✗ Branch 1 not taken.
7521864 if(close_button_quit)
4524 {
4525 close_button_quit=false;
4526 f_Quit(qEXIT);
4527 }
4528
4529 7521864 poll_joystick();
4530
4531
2/10
✓ Branch 0 taken 7521864 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7521864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
7521864 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4532 {
4533 oldtitle_version=title_version;
4534 System();
4535 }
4536
4537 7521864 mouse_down=gui_mouse_b();
4538
4539
1/2
✓ Branch 0 taken 7521864 times.
✗ Branch 1 not taken.
7521864 if(zc_read_system_key(KEY_F1))
4540 {
4541 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4542 {
4543 halt=!halt;
4544 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4545 }
4546 else
4547 {
4548 Throttlefps=!Throttlefps;
4549 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4550 logic_counter=0;
4551 }
4552 }
4553
4554 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4555 /*
4556 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4557 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4558 */
4559
4560
1/2
✓ Branch 0 taken 7521864 times.
✗ Branch 1 not taken.
7521864 if(zc_read_system_key(KEY_F2))
4561 {
4562 ShowFPS=!ShowFPS;
4563 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4564 }
4565
4566
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7521864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7521864 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4567
4568
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7521864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7521864 if(zc_read_system_key(KEY_F4) && Playing)
4569 {
4570 Paused=true;
4571 Advance=true;
4572 }
4573
4574
1/2
✓ Branch 0 taken 7521864 times.
✗ Branch 1 not taken.
7521864 if(zc_read_system_key(KEY_F6)) onTryQuit();
4575
4576 #ifndef ALLEGRO_MACOSX
4577
1/2
✓ Branch 0 taken 7521864 times.
✗ Branch 1 not taken.
7521864 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4578
4579
1/2
✓ Branch 0 taken 7521864 times.
✗ Branch 1 not taken.
7521864 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4580 #else
4581 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4582
4583 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4584 #endif
4585
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 7521864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
7521864 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4586
4587
1/2
✓ Branch 0 taken 7521864 times.
✗ Branch 1 not taken.
7521864 if (zc_read_system_key(KEY_F12))
4588 {
4589 onSnapshot();
4590 }
4591
4592
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7521864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7521864 if(debug_enabled && zc_read_system_key(KEY_TAB))
4593 set_debug(!get_debug());
4594
4595
1/2
✓ Branch 0 taken 7521864 times.
✗ Branch 1 not taken.
7521864 if(CheatModifierKeys())
4596 {
4597 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4598 {
4599 if(!bindable_cheat(c))
4600 continue;
4601 if(get_debug() || cheat >= cheat_lvl(c))
4602 {
4603 if(checkcheat(c))
4604 cheats_hit_bind(c);
4605 }
4606 }
4607 }
4608
4609
1/2
✓ Branch 0 taken 7521864 times.
✗ Branch 1 not taken.
7521864 if(volkeys)
4610 {
4611 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4612
4613 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4614
4615 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4616
4617 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4618 }
4619
4620
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 7521864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7521864 if(!get_debug() || !SystemKeys || replay_is_replaying())
4621 7521864 goto bottom;
4622
4623 if(zc_readkey(KEY_D))
4624 {
4625 details = !details;
4626 rectfill(screen,0,0,319,7,BLACK);
4627 rectfill(screen,0,8,31,239,BLACK);
4628 rectfill(screen,288,8,319,239,BLACK);
4629 rectfill(screen,32,232,287,239,BLACK);
4630 }
4631
4632 if(zc_readkey(KEY_P)) Paused=!Paused;
4633
4634 //if(zc_readkey(KEY_P)) centerHero();
4635 if(zc_readkey(KEY_A))
4636 {
4637 Paused=true;
4638 Advance=true;
4639 }
4640
4641 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4642 #ifndef ALLEGRO_MACOSX
4643 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4644
4645 if(zc_readkey(KEY_F7))
4646 {
4647 Matrix(ss_speed, ss_density, 0);
4648 game_pal();
4649 }
4650 #else
4651 // The reason these are different on Mac in the first place is that
4652 // the OS doesn't let us use F9 and F10...
4653 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4654
4655 if(zc_readkey(KEY_F9))
4656 {
4657 Matrix(ss_speed, ss_density, 0);
4658 game_pal();
4659 }
4660 #endif
4661 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4662 {
4663 //change containers
4664 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4665 {
4666 //magic containers
4667 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4668 {
4669 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4670 }
4671 else
4672 {
4673 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4674 }
4675 }
4676 else
4677 {
4678 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4679 {
4680 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4681 }
4682 else
4683 {
4684 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4685 }
4686 }
4687 }
4688
4689 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4690 {
4691 //change containers
4692 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4693 {
4694 //magic containers
4695 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4696 {
4697 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4698 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4699 //heart containers
4700 }
4701 else
4702 {
4703 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4704 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4705 }
4706 }
4707 else
4708 {
4709 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4710 {
4711 game->set_magic(zc_max(game->get_magic()-1,0));
4712 }
4713 else
4714 {
4715 game->set_life(zc_max(game->get_life()-1,0));
4716 }
4717 }
4718 }
4719
4720 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4721
4722 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4723
4724 verifyBothWeapons();
4725
4726 bottom:
4727
4728
1/2
✓ Branch 0 taken 7521864 times.
✗ Branch 1 not taken.
7521864 if(input_idle(true) > after_time())
4729 {
4730 Matrix(ss_speed, ss_density, 0);
4731 game_pal();
4732 }
4733 7521864 }
4734
4735 330136 void checkQuitKeys()
4736 {
4737 #ifndef ALLEGRO_MACOSX
4738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330136 times.
330136 if(key[KEY_F9]) f_Quit(qRESET);
4739
4740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330136 times.
330136 if(key[KEY_F10]) f_Quit(qEXIT);
4741 #else
4742 if(key[KEY_F7]) f_Quit(qRESET);
4743
4744 if(key[KEY_F8]) f_Quit(qEXIT);
4745 #endif
4746 330136 }
4747
4748 7521864 bool CheatModifierKeys()
4749 {
4750 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4751 // to trigger cheats.
4752
1/2
✓ Branch 0 taken 7521864 times.
✗ Branch 1 not taken.
7521864 if (replay_is_replaying())
4753 7521864 return false;
4754
4755 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4756 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4757 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4758 {
4759 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4760 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4761 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4762 {
4763 return true;
4764 }
4765 }
4766 return false;
4767 7521864 }
4768
4769 //99:05:54, for some reason?
4770 #define OLDMAXTIME 21405240
4771 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4772 #define MAXTIME 1944000000
4773
4774 7521922 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4775 {
4776
2/2
✓ Branch 0 taken 7243581 times.
✓ Branch 1 taken 278341 times.
7521922 if(zcmusic!=NULL)
4777 {
4778 278341 zcmusic_poll();
4779 278341 }
4780
4781 7521922 updatescr(allowwavy);
4782
4783 7521922 Advance=false;
4784
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 7521922 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7521922 times.
7521922 while(Paused && !Advance && !Quit)
4785 {
4786 // have to call this, otherwise we'll get an infinite loop
4787 syskeys();
4788 if(allowF6Script)
4789 {
4790 FFCore.runF6Engine();
4791 }
4792 throttleFPS();
4793
4794 #ifdef _WIN32
4795
4796 if(use_dwm_flush)
4797 {
4798 do_DwmFlush();
4799 }
4800
4801 #endif
4802
4803 // to keep music playing
4804 if(zcmusic!=NULL)
4805 {
4806 zcmusic_poll();
4807 }
4808
4809 update_hw_screen();
4810 }
4811
4812
2/2
✓ Branch 0 taken 7521875 times.
✓ Branch 1 taken 47 times.
7521922 if(Quit)
4813 47 return;
4814
4815
3/4
✓ Branch 0 taken 7427449 times.
✓ Branch 1 taken 94426 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7427449 times.
7521875 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4816 7427449 game->change_time(1);
4817
4818
3/4
✓ Branch 0 taken 7521875 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1011251 times.
✓ Branch 3 taken 6510624 times.
7521875 if (!replay_is_active() || replay_get_version() >= 11)
4819
2/2
✓ Branch 0 taken 18202518 times.
✓ Branch 1 taken 1011251 times.
19213769 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4820 19213769 down_control_states[i] = raw_control_state[i];
4821
4822
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 7521874 times.
7521875 if (replay_is_active())
4823 {
4824
2/2
✓ Branch 0 taken 1270462 times.
✓ Branch 1 taken 6251412 times.
7521874 if (replay_get_version() >= 3)
4825 6251412 replay_poll();
4826
4827
6/6
✓ Branch 0 taken 6510614 times.
✓ Branch 1 taken 1011250 times.
✓ Branch 2 taken 3089962 times.
✓ Branch 3 taken 3420652 times.
✓ Branch 4 taken 100535 times.
✓ Branch 5 taken 2989427 times.
7521874 if (replay_get_version() >= 11 || (replay_get_version() >= 6 && replay_get_version() < 8))
4828 1111785 replay_peek_input();
4829 7521864 }
4830
4831 7521875 load_control_called_this_frame = false;
4832
4833 7521875 poll_keyboard();
4834 7521875 update_keys();
4835
4836 7521875 ++frame;
4837
4838
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 7521864 times.
7521875 if (replay_is_replaying())
4839 7521864 replay_do_cheats();
4840 7521875 syskeys();
4841
4842 // The mouse variables can change from the mouse thread at anytime during a frame,
4843 // so save the result at the start so that replaying is consistent.
4844 7521875 script_mouse_x = gui_mouse_x();
4845 7521875 script_mouse_y = gui_mouse_y();
4846 7521875 script_mouse_z = mouse_z;
4847 7521875 script_mouse_b = mouse_b;
4848
4849 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4850 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4851 // approach here means it doesn't matter which call adds the cheat.
4852 7521875 cheats_execute_queued();
4853
4854
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 7521864 times.
7521875 if (replay_is_replaying())
4855 7521864 replay_peek_quit();
4856
2/2
✓ Branch 0 taken 7521861 times.
✓ Branch 1 taken 14 times.
7521875 if (GameFlags & GAMEFLAG_TRYQUIT)
4857 14 replay_step_quit(0);
4858
2/2
✓ Branch 0 taken 2201 times.
✓ Branch 1 taken 7519674 times.
7521875 if(allowF6Script)
4859 7519674 FFCore.runF6Engine();
4860
2/2
✓ Branch 0 taken 7521686 times.
✓ Branch 1 taken 189 times.
7521875 if (Quit)
4861 189 replay_step_quit(Quit);
4862 // Someday... maybe install a Turbo button here?
4863 7521875 throttleFPS();
4864
4865 #ifdef _WIN32
4866
4867 if(use_dwm_flush)
4868 {
4869 do_DwmFlush();
4870 }
4871
4872 #endif
4873
4874 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4875
2/2
✓ Branch 0 taken 40867 times.
✓ Branch 1 taken 7481008 times.
7521875 if(sfxcleanup)
4876 7481008 sfx_cleanup();
4877 7521922 }
4878
4879 69 void zapout()
4880 {
4881 69 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4882 69 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4883
4884 69 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4885 69 script_drawing_commands.Clear();
4886
4887 // zap out
4888
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 1656 times.
1725 for(int32_t i=1; i<=24; i++)
4889 {
4890 1656 draw_fuzzy(i);
4891 1656 advanceframe(true);
4892
4893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
1656 if(Quit)
4894 {
4895 break;
4896 }
4897 1656 }
4898 69 }
4899
4900 69 void zapin()
4901 {
4902 69 FFCore.warpScriptCheck();
4903 69 draw_screen(tmpscr);
4904 69 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4905 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4906 69 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4907
4908 // zap out
4909 69 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4910
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 1656 times.
1725 for(int32_t i=24; i>=1; i--)
4911 {
4912 1656 draw_fuzzy(i);
4913 1656 advanceframe(true);
4914
4915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
1656 if(Quit)
4916 {
4917 break;
4918 }
4919 1656 }
4920 69 }
4921
4922
4923 32 void wavyout(bool showhero)
4924 {
4925 32 draw_screen(tmpscr, showhero);
4926 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4927
4928 32 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4929 32 clear_to_color(wavebuf,0);
4930 32 blit(framebuf,wavebuf,0,0,16,0,256,224);
4931
4932 static PALETTE wavepal;
4933
4934 int32_t ofs;
4935 32 int32_t amplitude=8;
4936
4937 32 int32_t wavelength=4;
4938 32 double palpos=0, palstep=4, palstop=126;
4939
4940 32 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4941
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1344 times.
1376 for(int32_t i=0; i<168; i+=wavelength)
4942 {
4943
2/2
✓ Branch 0 taken 344064 times.
✓ Branch 1 taken 1344 times.
345408 for(int32_t l=0; l<256; l++)
4944 {
4945 344064 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4946 344064 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4947 344064 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4948 344064 }
4949
4950 1344 palpos+=palstep;
4951
4952
1/2
✓ Branch 0 taken 1344 times.
✗ Branch 1 not taken.
1344 if(palpos>=0)
4953 {
4954 1344 hw_palette = &wavepal;
4955 1344 update_hw_pal = true;
4956 1344 }
4957 else
4958 {
4959 hw_palette = &RAMpal;
4960 update_hw_pal = true;
4961 }
4962
4963
2/2
✓ Branch 0 taken 225792 times.
✓ Branch 1 taken 1344 times.
227136 for(int32_t j=0; j+playing_field_offset<224; j++)
4964 {
4965
2/2
✓ Branch 0 taken 57802752 times.
✓ Branch 1 taken 225792 times.
58028544 for(int32_t k=0; k<256; k++)
4966 {
4967 57802752 ofs=0;
4968
4969
4/4
✓ Branch 0 taken 28213248 times.
✓ Branch 1 taken 29589504 times.
✓ Branch 2 taken 14106624 times.
✓ Branch 3 taken 14106624 times.
57802752 if((j<i)&&(j&1))
4970 {
4971 14106624 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4972 14106624 }
4973
4974 57802752 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4975 57802752 }
4976 225792 }
4977
4978 1344 advanceframe(true);
4979
4980 // animate_combos();
4981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1344 times.
1344 if(Quit)
4982 break;
4983 1344 }
4984
4985 32 destroy_bitmap(wavebuf);
4986 32 }
4987
4988 32 void wavyin()
4989 {
4990 32 draw_screen(tmpscr);
4991 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4992
4993 32 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4994 32 clear_to_color(wavebuf,0);
4995 32 blit(framebuf,wavebuf,0,0,16,0,256,224);
4996
4997 static PALETTE wavepal;
4998
4999 //Breaks dark rooms.
5000 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
5001 /*
5002 loadfullpal();
5003 loadlvlpal(DMaps[currdmap].color);
5004 ringcolor(false);
5005 */
5006 32 refreshpal=false;
5007 int32_t ofs;
5008 32 int32_t amplitude=8;
5009 32 int32_t wavelength=4;
5010 32 double palpos=168, palstep=4, palstop=126;
5011
5012 32 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
5013
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1344 times.
1376 for(int32_t i=0; i<168; i+=wavelength)
5014 {
5015
2/2
✓ Branch 0 taken 344064 times.
✓ Branch 1 taken 1344 times.
345408 for(int32_t l=0; l<256; l++)
5016 {
5017 344064 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
5018 344064 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
5019 344064 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
5020 344064 }
5021
5022 1344 palpos-=palstep;
5023
5024
1/2
✓ Branch 0 taken 1344 times.
✗ Branch 1 not taken.
1344 if(palpos>=0)
5025 {
5026 1344 hw_palette = &wavepal;
5027 1344 update_hw_pal = true;
5028 1344 }
5029 else
5030 {
5031 hw_palette = &RAMpal;
5032 update_hw_pal = true;
5033 }
5034
5035
2/2
✓ Branch 0 taken 225792 times.
✓ Branch 1 taken 1344 times.
227136 for(int32_t j=0; j+playing_field_offset<224; j++)
5036 {
5037
2/2
✓ Branch 0 taken 57802752 times.
✓ Branch 1 taken 225792 times.
58028544 for(int32_t k=0; k<256; k++)
5038 {
5039 57802752 ofs=0;
5040
5041
4/4
✓ Branch 0 taken 29245440 times.
✓ Branch 1 taken 28557312 times.
✓ Branch 2 taken 14794752 times.
✓ Branch 3 taken 14450688 times.
57802752 if((j<(167-i))&&(j&1))
5042 {
5043 14450688 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
5044 14450688 }
5045
5046 57802752 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
5047 57802752 }
5048 225792 }
5049
5050 1344 advanceframe(true);
5051 // animate_combos();
5052
5053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1344 times.
1344 if(Quit)
5054 break;
5055 1344 }
5056
5057 32 destroy_bitmap(wavebuf);
5058 32 }
5059
5060 1826 void blackscr(int32_t fcnt,bool showsubscr)
5061 {
5062 1826 reset_pal_cycling();
5063 1826 script_drawing_commands.Clear();
5064
5065 1826 FFCore.warpScriptCheck();
5066 1826 bool showtime = game->should_show_time();
5067
2/2
✓ Branch 0 taken 1826 times.
✓ Branch 1 taken 54710 times.
56536 while(fcnt>0)
5068 {
5069 54710 clear_bitmap(framebuf);
5070
5071
2/2
✓ Branch 0 taken 17490 times.
✓ Branch 1 taken 37220 times.
54710 if(showsubscr)
5072 {
5073 37220 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
5074
3/4
✓ Branch 0 taken 37220 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 36470 times.
37220 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
5075 {
5076 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
5077 750 }
5078 37220 }
5079
5080 54710 advanceframe(true);
5081
5082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54710 times.
54710 if(Quit)
5083 break;
5084
5085 54710 --fcnt;
5086 }
5087 1826 }
5088
5089 645 void openscreen(int32_t shape)
5090 {
5091 645 reset_pal_cycling();
5092 645 black_opening_count=0;
5093
5094
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 547 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
645 if(COOLSCROLL || shape>-1)
5095 {
5096 547 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5097 547 return;
5098 }
5099 else
5100 {
5101 98 Hero.setDontDraw(true);
5102 98 show_subscreen_dmap_dots=false;
5103 98 show_subscreen_numbers=false;
5104 // show_subscreen_items=false;
5105 98 show_subscreen_life=false;
5106 }
5107
5108 98 int32_t x=128;
5109
5110 98 FFCore.warpScriptCheck();
5111
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 7840 times.
7938 for(int32_t i=0; i<80; i++)
5112 {
5113 7840 draw_screen(tmpscr);
5114 //? draw_screen already draws the subscreen -DD
5115 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5116 7840 x=128-(((i*128/80)/8)*8);
5117
5118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(x>0)
5119 {
5120 7840 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5121 7840 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5122 7840 }
5123
5124 7840 advanceframe(true);
5125
5126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(Quit)
5127 {
5128 break;
5129 }
5130 7840 }
5131
5132 98 Hero.setDontDraw(false);
5133 98 show_subscreen_items=true;
5134 98 show_subscreen_dmap_dots=true;
5135 645 }
5136
5137 void closescreen(int32_t shape)
5138 {
5139 reset_pal_cycling();
5140 black_opening_count=0;
5141
5142 if(COOLSCROLL || shape>-1)
5143 {
5144 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5145 return;
5146 }
5147 else
5148 {
5149 Hero.setDontDraw(true);
5150 show_subscreen_dmap_dots=false;
5151 show_subscreen_numbers=false;
5152 // show_subscreen_items=false;
5153 show_subscreen_life=false;
5154 }
5155
5156 int32_t x=128;
5157
5158 FFCore.warpScriptCheck();
5159 for(int32_t i=79; i>=0; --i)
5160 {
5161 draw_screen(tmpscr);
5162 //? draw_screen already draws the subscreen -DD
5163 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5164 x=128-(((i*128/80)/8)*8);
5165
5166 if(x>0)
5167 {
5168 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5169 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5170 }
5171
5172 advanceframe(true);
5173
5174 if(Quit)
5175 {
5176 break;
5177 }
5178 }
5179
5180 Hero.setDontDraw(false);
5181 show_subscreen_items=true;
5182 show_subscreen_dmap_dots=true;
5183 }
5184
5185 175 int32_t TriforceCount()
5186 {
5187 175 int32_t c=0;
5188
5189
2/2
✓ Branch 0 taken 1400 times.
✓ Branch 1 taken 175 times.
1575 for(int32_t i=1; i<=8; i++)
5190
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 1016 times.
2416 if(game->lvlitems[i]&liTRIFORCE)
5191 1016 ++c;
5192
5193 175 return c;
5194 }
5195
5196 int32_t onCustomGame()
5197 {
5198 int32_t file = getsaveslot();
5199
5200 if(file < 0)
5201 return D_O_K;
5202
5203 bool ret = (custom_game(file)!=0);
5204 return ret ? D_CLOSE : D_O_K;
5205 }
5206
5207 int32_t onContinue()
5208 {
5209 return D_CLOSE;
5210 }
5211
5212 int32_t onEsc() // Unused?? -L
5213 {
5214 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5215 }
5216
5217 int32_t onVsync()
5218 {
5219 Throttlefps = !Throttlefps;
5220 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5221 return D_O_K;
5222 }
5223
5224 int32_t onWinPosSave()
5225 {
5226 SaveWinPos = !SaveWinPos;
5227 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5228 return D_O_K;
5229 }
5230 int32_t onIntegerScaling()
5231 {
5232 scaleForceInteger = !scaleForceInteger;
5233 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5234 return D_O_K;
5235 }
5236 int32_t onStretchGame()
5237 {
5238 stretchGame = !stretchGame;
5239 zc_set_config("zeldadx","stretch_game_area",stretchGame?1:0);
5240 return D_O_K;
5241 }
5242
5243 int32_t onClickToFreeze()
5244 {
5245 ClickToFreeze = !ClickToFreeze;
5246 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5247 return D_O_K;
5248 }
5249
5250 int32_t OnSaveZCConfig()
5251 {
5252 if(jwin_alert3(
5253 "Save Configuration",
5254 "Are you sure that you wish to save your present configuration settings?",
5255 "This will overwrite your prior settings!",
5256 NULL,
5257 "&Yes",
5258 "&No",
5259 NULL,
5260 'y',
5261 'n',
5262 0,
5263 get_zc_font(font_lfont)) == 1)
5264 {
5265 save_game_configs();
5266 return D_O_K;
5267 }
5268 else return D_O_K;
5269 }
5270
5271 int32_t OnnClearQuestDir()
5272 {
5273 if(jwin_alert3(
5274 "Clear Current Directory Cache",
5275 "Are you sure that you wish to clear the current cached directory?",
5276 "This will default the current directory to the ROOT for this instance of ZC Player!",
5277 NULL,
5278 "&Yes",
5279 "&No",
5280 NULL,
5281 'y',
5282 'n',
5283 0,
5284 get_zc_font(font_lfont)) == 1)
5285 {
5286 zc_set_config("zeldadx","win_qst_dir","");
5287 flush_config_file();
5288 strcpy(qstdir,"");
5289 #ifdef __EMSCRIPTEN__
5290 em_sync_fs();
5291 #endif
5292 return D_O_K;
5293 }
5294 else return D_O_K;
5295 }
5296
5297
5298 int32_t onConsoleZASM()
5299 {
5300 if ( !zasm_debugger )
5301 {
5302 AlertDialog("WARNING: ZASM Debugger",
5303 "Enabling this will open the ZASM Debugger Console"
5304 "\nThis will likely grind ZC to a halt with lag."
5305 "\nTo make any use of this, it is suggested that you read"
5306 "\nthe documentation for 'void Breakpoint(char[] string);'"
5307 " in 'ZScript_Additions.txt'"
5308 "\nThis is not recommended for normal users,"
5309 " and is only intended for ZC developers,"
5310 "\nor quest developers coding directly in ZASM"
5311 "\nAre you sure that you wish to open the ZASM Debugger?",
5312 [&](bool ret,bool)
5313 {
5314 if(ret)
5315 {
5316 FFCore.ZASMPrint(true);
5317 }
5318 }).show();
5319 return D_O_K;
5320 }
5321 else
5322 {
5323 FFCore.ZASMPrint(false);
5324 return D_O_K;
5325 }
5326 }
5327
5328
5329 int32_t onConsoleZScript()
5330 {
5331 if ( !zscript_debugger )
5332 {
5333 AlertDialog("ZScript Debugger",
5334 "Enabling this will open the ZScript Debugger Console"
5335 "\nThis will display any messages logged by scripts,"
5336 " including script errors."
5337 "\nAre you sure that you wish to open the ZScript Debugger?",
5338 [&](bool ret,bool)
5339 {
5340 if(ret)
5341 {
5342 FFCore.ZScriptConsole(true);
5343 }
5344 }).show();
5345 return D_O_K;
5346 }
5347 else
5348 {
5349 FFCore.ZScriptConsole(false);
5350 return D_O_K;
5351 }
5352 }
5353
5354 int32_t onClrConsoleOnReload()
5355 {
5356 clearConsoleOnReload = !clearConsoleOnReload;
5357 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5358 return D_O_K;
5359 }
5360 int32_t onClrConsoleOnLoad()
5361 {
5362 clearConsoleOnLoad = !clearConsoleOnLoad;
5363 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5364 return D_O_K;
5365 }
5366
5367
5368 int32_t onFrameSkip()
5369 {
5370 FrameSkip = !FrameSkip;
5371 return D_O_K;
5372 }
5373
5374 int32_t onSaveDragResize()
5375 {
5376 SaveDragResize = !SaveDragResize;
5377 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5378 return D_O_K;
5379 }
5380
5381 int32_t onDragAspect()
5382 {
5383 DragAspect = !DragAspect;
5384 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5385 return D_O_K;
5386 }
5387
5388 int32_t onTransLayers()
5389 {
5390 TransLayers = !TransLayers;
5391 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5392 return D_O_K;
5393 }
5394
5395 int32_t onNESquit()
5396 {
5397 NESquit = !NESquit;
5398 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5399 return D_O_K;
5400 }
5401
5402 int32_t onVolKeys()
5403 {
5404 volkeys = !volkeys;
5405 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5406 return D_O_K;
5407 }
5408
5409 int32_t onShowFPS()
5410 {
5411 ShowFPS = !ShowFPS;
5412 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5413 return D_O_K;
5414 }
5415
5416 887579952 bool is_Fkey(int32_t k)
5417 {
5418
2/2
✓ Branch 0 taken 90262368 times.
✓ Branch 1 taken 797317584 times.
887579952 switch(k)
5419 {
5420 case KEY_F1:
5421 case KEY_F2:
5422 case KEY_F3:
5423 case KEY_F4:
5424 case KEY_F5:
5425 case KEY_F6:
5426 case KEY_F7:
5427 case KEY_F8:
5428 case KEY_F9:
5429 case KEY_F10:
5430 case KEY_F11:
5431 case KEY_F12:
5432 90262368 return true;
5433 }
5434
5435 797317584 return false;
5436 887579952 }
5437
5438 void kb_getkey(DIALOG *d);
5439
5440 //Used by all keyboard key settings dialogues.
5441 void kb_clearjoystick(DIALOG *d)
5442 {
5443 d->flags|=D_SELECTED;
5444
5445 jwin_button_proc(MSG_DRAW,d,0);
5446 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5447 // text_mode(vc(11));
5448 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5449 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5450
5451 update_hw_screen(true);
5452
5453 clear_keybuf();
5454 int32_t k = next_press_key();
5455 clear_keybuf();
5456
5457 //shnarf
5458 //47=f1
5459 //59=esc
5460 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5461 // *((int32_t*)d->dp3) = k;
5462 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5463
5464
5465 d->flags&=~D_SELECTED;
5466 }
5467
5468 //Clears key to 0.
5469 //Used by all keyboard key settings dialogues.
5470 void kb_clearkey(DIALOG *d);
5471
5472 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5473 {
5474 switch(msg)
5475 {
5476 case MSG_KEY:
5477 case MSG_CLICK:
5478
5479 kb_clearjoystick(d);
5480
5481 while(gui_mouse_b())
5482 {
5483 clear_keybuf();
5484 rest(1);
5485 }
5486
5487 return D_REDRAW;
5488 }
5489
5490 return jwin_button_proc(msg,d,c);
5491 }
5492
5493 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5494 //Only used in keyboard settings dialogues to clear keys.
5495 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5496
5497 void j_getbtn(DIALOG *d)
5498 {
5499 d->flags|=D_SELECTED;
5500 jwin_button_proc(MSG_DRAW,d,0);
5501 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5502 // text_mode(vc(11));
5503 int32_t y = gui_bmp->h/2 - 12;
5504 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5505 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5506 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5507
5508 update_hw_screen(true);
5509
5510 int32_t b = next_press_btn();
5511
5512 if(b>=0)
5513 *((int32_t*)d->dp3) = b;
5514
5515 d->flags&=~D_SELECTED;
5516
5517 if (player)
5518 player->joy_on = TRUE;
5519 }
5520
5521 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5522 {
5523 switch(msg)
5524 {
5525 case MSG_KEY:
5526 case MSG_CLICK:
5527
5528 j_getbtn(d);
5529
5530 while(gui_mouse_b()) {
5531 rest(1);
5532 clear_keybuf();
5533 }
5534
5535 return D_REDRAW;
5536 }
5537
5538 return jwin_button_proc(msg,d,c);
5539 }
5540
5541 //shnarf
5542 extern const char *key_str[];
5543 std::string get_keystr(int key);
5544
5545 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5546 //extern int32_t zcmusic_bufsz;
5547
5548 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5549 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5550
5551 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5552 {
5553 //these are here to bypass compiler warnings about unused arguments
5554 c=c;
5555
5556 if(msg==MSG_DRAW)
5557 {
5558 switch(d->w)
5559 {
5560 case 0:
5561 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5562 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5563 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5564 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5565 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5566 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5567 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5568 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5569 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5570 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5571 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5572 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5573 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5574 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5575 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5576 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5577 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5578 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5579 break;
5580
5581 case 1:
5582 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5583 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5584 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5585 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5586 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5587 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5588 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5589 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5590 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5591 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5592 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5593 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5594 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5595 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5596 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5597 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5598 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5599 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5600 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5601 break;
5602
5603 case 2:
5604 sprintf(str_a," %3d",midi_volume);
5605 sprintf(str_b," %3d",digi_volume);
5606 sprintf(str_l," %3d",emusic_volume);
5607 sprintf(str_m," %3dKB",zcmusic_bufsz);
5608 sprintf(str_r," %3d",sfx_volume);
5609 strcpy(str_s,pan_str[pan_style]);
5610 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5611 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5612 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5613 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5614 break;
5615 }
5616 }
5617
5618 return D_O_K;
5619 }
5620
5621 int32_t set_vol(void *dp3, int32_t d2)
5622 {
5623 switch(((int32_t*)dp3)[0])
5624 {
5625 case 0:
5626 midi_volume = zc_min(d2<<3,255);
5627 break;
5628
5629 case 1:
5630 digi_volume = zc_min(d2<<3,255);
5631 break;
5632
5633 case 2:
5634 emusic_volume = zc_min(d2<<3,255);
5635 break;
5636
5637 case 3:
5638 sfx_volume = zc_min(d2<<3,255);
5639 break;
5640 }
5641
5642 // text_mode(vc(11));
5643 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5644 return D_O_K;
5645 }
5646
5647 int32_t set_pan(void *dp3, int32_t d2)
5648 {
5649 pan_style = vbound(d2,0,3);
5650 // text_mode(vc(11));
5651 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5652 return D_O_K;
5653 }
5654
5655 int32_t set_buf(void *dp3, int32_t d2)
5656 {
5657 // text_mode(vc(11));
5658 zcmusic_bufsz = d2 + 1;
5659 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5660 return D_O_K;
5661 }
5662
5663 static int32_t gamepad_btn_list[] =
5664 {
5665 6,
5666 7,8,9,10,11,12,13,14,15,16,17,
5667 18,19,20,21,22,23,24,25,26,27,28,
5668 29,30,31,32,33,34,35,36,37,38,39,
5669 -1
5670 };
5671
5672 static int32_t gamepad_dirs_list[] =
5673 {
5674 40,41,42,43,
5675 44,45,46,47,
5676 48,49,50,51,
5677 52,53,54,55,
5678 56,
5679 -1
5680 };
5681
5682 static TABPANEL gamepad_tabs[] =
5683 {
5684 // (text)
5685 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5686 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5687 { NULL, 0, NULL, 0, NULL }
5688 };
5689
5690 static DIALOG gamepad_dlg[] =
5691 {
5692 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5693 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5694 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5695 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5696 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5697 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5698 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5699 // 6
5700 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5701 // 7
5702 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5703 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5704 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5705 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5706 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5707 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5708 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5709 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5710 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5711 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5712 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5713 // 18
5714 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5715 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5716 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5717 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5718 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5719 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5720 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5721 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5722 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5723 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5724 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5725 // 29
5726 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5727 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5728 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5729 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5730 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5731 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5732 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5733 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5734 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5735 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5736 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5737 // 40
5738 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5739 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5740 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5741 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5742 // 44
5743 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5744 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5745 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5746 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5747 // 48
5748 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5749 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5750 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5751 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5752 // 52
5753 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5754 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5755 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5756 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5757 // 56
5758 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5759 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5760 };
5761
5762 static int32_t keyboard_keys_list[] =
5763 {
5764 6,7,8,9,10,
5765 11,12,13,14,15,16,17,18,19,20,
5766 21,22,23,24,25,26,27,28,29,30,
5767 31,32,33,34,35,36,37,38,39,40,
5768 -1
5769 };
5770
5771 static int32_t keyboard_dirs_list[] =
5772 {
5773 41,42,43,44,
5774 45,46,47,48,
5775 49,50,51,52,
5776 53,54,55,56,
5777 -1
5778 };
5779
5780 static int32_t keyboard_mods_list[] =
5781 {
5782 57,58,59,60,
5783 61,62,63,64,
5784 65,66,67,68,
5785 69,70,71,72,
5786 -1
5787 };
5788
5789 static TABPANEL keyboard_control_tabs[] =
5790 {
5791 // (text)
5792 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5793 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5794 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5795 { NULL, 0, NULL, 0, NULL }
5796 };
5797
5798 static DIALOG keyboard_control_dlg[] =
5799 {
5800 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5801 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5802 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5803 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5804 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5805 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5806 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5807 // Keys
5808 // 6
5809 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5810 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5811 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5812 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5813 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5814 // 11
5815 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5816 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5817 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5818 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5819 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5820 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5821 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5822 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5823 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5824 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5825 // 21
5826 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5827 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5828 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5829 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5830 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5831 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5832 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5833 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5834 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5835 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5836 // 31
5837 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5838 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5839 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5840 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5841 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5842 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5843 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5844 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5845 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5846 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5847 // Dirs
5848 // 41
5849 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5850 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5851 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5852 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5853 // 45
5854 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5855 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5856 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5857 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5858 // 49
5859 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5860 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5861 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5862 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5863 // 53
5864 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5865 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5866 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5867 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5868 // Mods
5869 // 57
5870 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5871 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5872 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5873 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5874 // 61
5875 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5876 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5877 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5878 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5879 // 65
5880 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5881 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5882 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5883 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5884 // 69
5885 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5886 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5887 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5888 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5889 // 73
5890 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5891 };
5892
5893 /*
5894 int32_t midi_dp[3] = {0,147,104};
5895 int32_t digi_dp[3] = {1,147,120};
5896 int32_t pan_dp[3] = {0,147,136};
5897 int32_t buf_dp[3] = {0,147,152};
5898 */
5899 int32_t midi_dp[3] = {0,0,0};
5900 int32_t digi_dp[3] = {1,0,0};
5901 int32_t emus_dp[3] = {2,0,0};
5902 int32_t buf_dp[3] = {0,0,0};
5903 int32_t sfx_dp[3] = {3,0,0};
5904 int32_t pan_dp[3] = {0,0,0};
5905
5906 static DIALOG sound_dlg[] =
5907 {
5908 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5909 31 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5910 31 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5911 31 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5912 31 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5913 31 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5914 31 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5915 31 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5916 31 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5917 31 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5918 31 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5919 // 10
5920 31 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5921 31 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5922 31 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5923 31 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5924 31 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5925 31 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5926 31 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5927 31 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5928 31 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5929 31 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5930 //20
5931 31 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5932 31 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5933 31 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5934 31 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5935 31 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5936 31 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5937 31 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5938 31 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5939 31 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5940 31 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5941 //30
5942 31 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5943 31 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5944 31 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5945 31 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5946 };
5947
5948 char zc_builddate[80];
5949 char zc_aboutstr[80];
5950
5951 static DIALOG about_dlg[] =
5952 {
5953 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5954 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5955 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5956 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5957 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5958 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5959 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5960 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5961 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5962 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5963 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5964 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5965 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5966 };
5967
5968
5969 static DIALOG quest_dlg[] =
5970 {
5971 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5972 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5973 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5974 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5975 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5976 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5977 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5978 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5979 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5980 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5981 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5982 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5983 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5984 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5985 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5986 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5987 };
5988
5989 static DIALOG triforce_dlg[] =
5990 {
5991 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5992 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5993 // 1
5994 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5995 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5996 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5997 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5998 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5999 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
6000 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
6001 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
6002 // 9
6003 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6004 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6005 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6006 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6007 };
6008
6009 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6010 {
6011 go();
6012 int32_t ret=0;
6013 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
6014 comeback();
6015 return ret != 0;
6016 }
6017
6018
6019 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6020 {
6021 if(def!=modulepath)
6022 strcpy(modulepath,def);
6023
6024 if(!usefilename)
6025 {
6026 int32_t i=(int32_t)strlen(modulepath);
6027
6028 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
6029 modulepath[i--]=0;
6030 }
6031
6032 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6033 int32_t ret=0;
6034 int32_t sel=0;
6035
6036 if(list==NULL)
6037 {
6038 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,get_zc_font(font_lfont));
6039 }
6040 else
6041 {
6042 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
6043 }
6044
6045 return ret!=0;
6046 }
6047
6048 //The Dialogue that loads a ZMOD Module File
6049 int32_t zc_load_zmod_module_file()
6050 {
6051 if ( Playing )
6052 {
6053 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
6054 return -1;
6055 }
6056 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
6057 return D_CLOSE;
6058
6059 FILE *tempmodule = fopen(modulepath,"r");
6060
6061 if(tempmodule == NULL)
6062 {
6063 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
6064 return -1;
6065 }
6066
6067
6068 //Set the module path:
6069 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6070 strcpy(moduledata.module_name, modulepath);
6071 al_trace("New Module Path is: %s \n", moduledata.module_name);
6072 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
6073 zcm.init(true); //Load the module values.
6074 moduledata.refresh_title_screen = 1;
6075 // refresh_select_screen = 1;
6076 build_biic_list();
6077 return D_O_K;
6078 }
6079
6080 static DIALOG module_info_dlg[] =
6081 {
6082 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6083
6084
6085 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6086 //1
6087 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6088 //2
6089 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6090 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6091 //4
6092 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6093 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6094 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6095 //7
6096
6097 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6098 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6099 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6100 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6101 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6102 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6103 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6104 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6105 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6106
6107 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6108 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6109 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6110 };
6111
6112 void about_zcplayer_module(const char *prompt,int32_t initialval)
6113 {
6114
6115 module_info_dlg[0].dp2 = get_zc_font(font_lfont);
6116 if ( moduledata.moduletitle[0] != 0 )
6117 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6118
6119 if ( moduledata.moduleauthor[0] != 0 )
6120 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6121
6122 if ( moduledata.moduleinfo0[0] != 0 )
6123 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6124 if ( moduledata.moduleinfo1[0] != 0 )
6125 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6126 if ( moduledata.moduleinfo2[0] != 0 )
6127 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6128 if ( moduledata.moduleinfo3[0] != 0 )
6129 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6130 if ( moduledata.moduleinfo4[0] != 0 )
6131 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6132
6133 char module_date[255];
6134 memset(module_date, 0, sizeof(module_date));
6135 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6136 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6137
6138
6139
6140 char module_vers[255];
6141 memset(module_vers, 0, sizeof(module_vers));
6142 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6143
6144
6145 //sprintf(tilecount,"%d",1);
6146
6147 char module_build[255];
6148 memset(module_build, 0, sizeof(module_build));
6149 if ( moduledata.modbeta )
6150 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6151 else
6152 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6153
6154 module_info_dlg[12].dp = (char*)module_date;
6155 module_info_dlg[13].dp = (char*)module_vers;
6156 module_info_dlg[14].dp = (char*)module_build;
6157
6158 large_dialog(module_info_dlg);
6159
6160 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6161 jwin_center_dialog(module_info_dlg);
6162
6163
6164 }
6165
6166 int32_t onAbout_ZCP_Module()
6167 {
6168 about_zcplayer_module("About Module (.zmod)", 0);
6169 return D_O_K;
6170 }
6171
6172 //New Modules Menu for 2.55+
6173 static MENU zcmodule_menu[] =
6174 {
6175 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6176 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6177
6178 { NULL, NULL, NULL, 0, NULL }
6179 };
6180
6181 int32_t onToggleRecordingNewSaves()
6182 {
6183 if (zc_get_config("zeldadx", "replay_new_saves", false))
6184 {
6185 zc_set_config("zeldadx", "replay_new_saves", false);
6186 }
6187 else
6188 {
6189 zc_set_config("zeldadx", "replay_new_saves", true);
6190 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6191 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6192 }
6193 return D_O_K;
6194 }
6195
6196 int32_t onToggleSnapshotAllFrames()
6197 {
6198 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6199 return D_O_K;
6200 }
6201
6202 int32_t onStopReplayOrRecord()
6203 {
6204 if (replay_is_replaying())
6205 {
6206 replay_quit();
6207 }
6208 else if (replay_get_mode() == ReplayMode::Record)
6209 {
6210 if (!replay_get_meta_bool("test_mode"))
6211 {
6212 jwin_alert("Recording", "You cannot stop recording a save file.",
6213 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6214 return D_CLOSE;
6215 }
6216
6217 if (jwin_alert("Stop Recording",
6218 "Save replay to disk and stop recording?",
6219 "This will stop the recording.",
6220 NULL,
6221 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6222 return D_CLOSE;
6223
6224 replay_save();
6225 replay_stop();
6226 }
6227 return D_O_K;
6228 }
6229
6230 static int32_t handle_on_load_replay(ReplayMode mode)
6231 {
6232 if (Playing)
6233 {
6234 if (jwin_alert("Replay - Warning!",
6235 "Loading a replay will exit the current game.",
6236 "All unsaved progress will be lost.",
6237 "Do you wish to continue?",
6238 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6239 return D_CLOSE;
6240 }
6241
6242 std::string mode_string = replay_mode_to_string(mode);
6243 mode_string[0] = std::toupper(mode_string[0]);
6244
6245 std::string line_1 = "Select a replay file to play back.";
6246 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6247 std::string line_3 = "You can stop the replay and take over manually any time.";
6248 if (mode == ReplayMode::Update)
6249 {
6250 line_1 = "Select a replay file to update.";
6251 line_2 = "WARNING: be sure to back up the zplay file";
6252 line_3 = "and verify that the updated replay works as expected!";
6253 }
6254
6255 if (jwin_alert(mode_string.c_str(),
6256 line_1.c_str(),
6257 line_2.c_str(),
6258 line_3.c_str(),
6259 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
6260 {
6261 char replay_path[2048];
6262 strcpy(replay_path, "replays/");
6263 if (jwin_file_select_ex(
6264 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6265 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6266 return D_CLOSE;
6267
6268 replay_quit();
6269 load_replay_file_deferred(mode, replay_path);
6270 Quit = qRESET;
6271 return D_CLOSE;
6272 }
6273 return D_O_K;
6274 }
6275
6276 int32_t onLoadReplay()
6277 {
6278 return handle_on_load_replay(ReplayMode::Replay);
6279 }
6280
6281 int32_t onLoadReplayAssert()
6282 {
6283 return handle_on_load_replay(ReplayMode::Assert);
6284 }
6285
6286 int32_t onLoadReplayUpdate()
6287 {
6288 return handle_on_load_replay(ReplayMode::Update);
6289 }
6290
6291 int32_t onSaveReplay()
6292 {
6293 if (replay_get_mode() == ReplayMode::Record)
6294 {
6295 if (!replay_get_meta_bool("test_mode"))
6296 {
6297 if (jwin_alert("Save Replay",
6298 "This will save a copy of the replay up to this point.",
6299 "The official replay file will be untouched.",
6300 "Do you wish to continue?",
6301 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6302 return D_CLOSE;
6303
6304 char replay_path[2048];
6305 strcpy(replay_path, replay_get_replay_path().string().c_str());
6306 if (jwin_file_select_ex(
6307 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6308 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6309 return D_CLOSE;
6310
6311 if (fileexists(replay_path))
6312 {
6313 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6314 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6315 return D_CLOSE;
6316 }
6317
6318 replay_save(replay_path);
6319 }
6320 else
6321 {
6322 replay_save();
6323 }
6324 }
6325 return D_O_K;
6326 }
6327
6328 static MENU replay_menu[] =
6329 {
6330 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6331 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6332 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6333 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6334 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6335 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6336 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6337
6338 { NULL, NULL, NULL, 0, NULL }
6339 };
6340
6341 static DIALOG credits_dlg[] =
6342 {
6343 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6344 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6345 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6346 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6347 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6348 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6349 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6350 };
6351
6352 31 static ListData dmap_list(dmaplist, &font);
6353
6354 static DIALOG goto_dlg[] =
6355 {
6356 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6357 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6358 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6359 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6360 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6361 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6362 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6363 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6364 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6365 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6366 };
6367
6368 int32_t onGoTo()
6369 {
6370 bool music = false;
6371 music = music;
6372 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6373
6374 goto_dlg[0].dp2=get_zc_font(font_lfont);
6375 goto_dlg[4].d2=cheat_goto_dmap;
6376 goto_dlg[6].dp=cheat_goto_screen_str;
6377
6378 clear_keybuf();
6379
6380 large_dialog(goto_dlg);
6381
6382 if(zc_popup_dialog(goto_dlg,4)==1)
6383 {
6384 // dmap, screen
6385 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6386 };
6387
6388 return D_O_K;
6389 }
6390
6391 int32_t onGoToComplete()
6392 {
6393 if(!Playing)
6394 {
6395 return D_O_K;
6396 }
6397
6398 system_pal();
6399 music_pause();
6400 pause_all_sfx();
6401 sys_mouse();
6402 onGoTo();
6403 eat_buttons();
6404
6405 zc_readrawkey(KEY_ESC);
6406
6407 game_mouse();
6408 game_pal();
6409 music_resume();
6410 resume_all_sfx();
6411 return D_O_K;
6412 }
6413
6414 int32_t onCredits()
6415 {
6416 go();
6417
6418 BITMAP *win = create_bitmap_ex(8,222,110);
6419
6420 if(!win)
6421 return D_O_K;
6422
6423 int32_t c=0;
6424 int32_t l=0;
6425 int32_t ol=-1;
6426 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6427 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6428 PALETTE tmppal;
6429
6430 rti_gui.transparency_index = 1;
6431
6432 clear_to_color(win, rti_gui.transparency_index);
6433 draw_rle_sprite(win,rle,0,0);
6434 credits_dlg[0].dp2=get_zc_font(font_lfont);
6435 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6436 credits_dlg[2].dp = win;
6437
6438 zc_set_palette_range(black_palette,0,127,false);
6439
6440 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6441
6442 BITMAP* old_screen = screen;
6443 BITMAP* gui_bmp = zc_get_gui_bmp();
6444 ASSERT(gui_bmp);
6445 clear_to_color(gui_bmp, rti_gui.transparency_index);
6446 screen = gui_bmp;
6447
6448 while(update_dialog(p))
6449 {
6450 throttleFPS();
6451 ++c;
6452 l = zc_max((c>>1)-30,0);
6453
6454 if(l > rle->h)
6455 l = c = 0;
6456
6457 if(l > rle->h - 112)
6458 l = rle->h - 112;
6459
6460 clear_bitmap(win);
6461 draw_rle_sprite(win,rle,0,0-l);
6462
6463 if(c<=64)
6464 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6465
6466 zc_set_palette_range(tmppal,0,127,false);
6467
6468 if(l!=ol)
6469 {
6470 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6471 SCRFIX();
6472 ol=l;
6473 }
6474
6475 update_hw_screen();
6476 }
6477
6478 screen = old_screen;
6479 system_pal();
6480
6481 shutdown_dialog(p);
6482 destroy_bitmap(win);
6483 //comeback();
6484
6485 rti_gui.transparency_index = 0;
6486 clear_to_color(gui_bmp, rti_gui.transparency_index);
6487
6488 return D_O_K;
6489 }
6490
6491 const char *midilist(int32_t index, int32_t *list_size)
6492 {
6493 if(index<0)
6494 {
6495 *list_size=0;
6496
6497 for(int32_t i=0; i<MAXMIDIS; i++)
6498 if(tunes[i].data)
6499 ++(*list_size);
6500
6501 return NULL;
6502 }
6503
6504 int32_t i=0,m=0;
6505
6506 while(m<=index && i<=MAXMIDIS)
6507 {
6508 if(tunes[i].data)
6509 ++m;
6510
6511 ++i;
6512 }
6513
6514 --i;
6515
6516 if(i==MAXMIDIS && m<index)
6517 return "(null)";
6518
6519 return tunes[i].title;
6520 }
6521
6522 /* ------- MIDI info stuff -------- */
6523
6524 char *text;
6525 midi_info *zmi;
6526 bool dialog_running;
6527 bool listening;
6528
6529 void get_info(int32_t index);
6530
6531 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6532 {
6533 int32_t d2 = d->d2;
6534 int32_t ret = jwin_droplist_proc(msg,d,c);
6535
6536 if(d2!=d->d2)
6537 {
6538 get_info(d->d2);
6539 }
6540
6541 return ret;
6542 }
6543
6544 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6545 {
6546 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6547
6548 int32_t ret = jwin_button_proc(msg,d,c);
6549
6550 if(ret == D_CLOSE)
6551 {
6552 // get current midi index
6553 int32_t index = (d+(d->d1))->d2;
6554 int32_t i=0, m=0;
6555
6556 while(m<=index && i<=MAXMIDIS)
6557 {
6558 if(tunes[i].data)
6559 ++m;
6560
6561 ++i;
6562 }
6563
6564 --i;
6565 jukebox(i);
6566 listening = true;
6567 ret = D_O_K;
6568 }
6569
6570 return ret;
6571 }
6572
6573 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6574 {
6575 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6576
6577 int32_t ret = jwin_button_proc(msg,d,c);
6578
6579 if(ret == D_CLOSE)
6580 {
6581 // get current midi index
6582 int32_t index = (d+(d->d1))->d2;
6583 int32_t i=0, m=0;
6584
6585 while(m<=index && i<=MAXMIDIS)
6586 {
6587 if(tunes[i].data)
6588 ++m;
6589
6590 ++i;
6591 }
6592
6593 --i;
6594
6595 // get file name
6596
6597 int32_t sel=0;
6598 //struct ffblk f;
6599 char title[40] = "Save MIDI: ";
6600 char fname[2048];
6601 memset(fname,0,2048);
6602 static EXT_LIST list[] =
6603 {
6604 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6605 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6606 { NULL, NULL }
6607 };
6608
6609 strcpy(title+11, tunes[i].title);
6610 title[39] = '\0';
6611
6612 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, get_zc_font(font_lfont))==0)
6613 goto done;
6614
6615 if(exists(fname))
6616 {
6617 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6618 goto done;
6619 }
6620
6621 // save midi i
6622
6623 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6624 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6625
6626 done:
6627 chop_path(fname);
6628 ret = D_REDRAW;
6629 }
6630
6631 return ret;
6632 }
6633
6634 31 static ListData midi_list(midilist, &font);
6635
6636 static DIALOG midi_dlg[] =
6637 {
6638 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6639 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6640 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6641 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6642 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6643 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6644 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6645 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6646 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6647 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6648 };
6649
6650 void get_info(int32_t index)
6651 {
6652 int32_t i=0, m=0;
6653
6654 while(m<=index && i<=MAXMIDIS)
6655 {
6656 if(tunes[i].data)
6657 ++m;
6658
6659 ++i;
6660 }
6661
6662 --i;
6663
6664 if(i==MAXMIDIS && m<index)
6665 strcpy(text,"(null)");
6666 else
6667 {
6668 get_midi_info((MIDI*)tunes[i].data,zmi);
6669 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6670 }
6671
6672 midi_dlg[0].dp2=get_zc_font(font_lfont);
6673 midi_dlg[3].dp = text;
6674 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6675 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6676
6677 if(dialog_running)
6678 {
6679 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6680 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6681 }
6682 }
6683
6684 int32_t onMIDICredits()
6685 {
6686 text = (char*)malloc(4096);
6687 zmi = (midi_info*)malloc(sizeof(midi_info));
6688
6689 if(!text || !zmi)
6690 {
6691 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6692 return D_O_K;
6693 }
6694
6695 bool do_pause_midi = midi_pos >= 0 && currmidi;
6696 auto restore_midi = currmidi;
6697 if(do_pause_midi)
6698 {
6699 paused_midi_pos = midi_pos;
6700 stop_midi();
6701 midi_paused=true;
6702 midi_suspended = midissuspHALTED;
6703 }
6704
6705 midi_dlg[0].dp2=get_zc_font(font_lfont);
6706 midi_dlg[2].d1 = 0;
6707 midi_dlg[2].d2 = 0;
6708 midi_dlg[4].flags = D_EXIT;
6709 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6710
6711 listening = false;
6712 dialog_running=false;
6713 get_info(0);
6714
6715 dialog_running=true;
6716
6717 large_dialog(midi_dlg);
6718
6719 zc_popup_dialog(midi_dlg,0);
6720 dialog_running=false;
6721
6722 if(listening)
6723 music_stop();
6724
6725 if(do_pause_midi)
6726 {
6727 midi_suspended = midissuspRESUME;
6728 currmidi = restore_midi;
6729 midi_pos = paused_midi_pos;
6730 }
6731
6732 if(text) free(text);
6733 if(zmi) free(zmi);
6734 return D_O_K;
6735 }
6736
6737 int32_t onAbout()
6738 {
6739 char buf1[80]={0};
6740 std::ostringstream oss;
6741 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6742 oss << buf1 << '\n';
6743 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6744 oss << buf1 << '\n';
6745 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6746 oss << buf1 << '\n';
6747 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6748 oss << buf1 << '\n';
6749 sprintf(buf1, "Tag: %s", getReleaseTag());
6750 oss << buf1 << '\n';
6751
6752 InfoDialog("About ZC", oss.str()).show();
6753 return D_O_K;
6754 }
6755
6756 int32_t onQuest()
6757 {
6758 char fname[100];
6759 strcpy(fname, get_filename(qstpath));
6760 quest_dlg[0].dp2=get_zc_font(font_lfont);
6761 quest_dlg[1].dp = fname;
6762
6763 if(QHeader.quest_number==0)
6764 sprintf(str_a,"Custom");
6765 else
6766 sprintf(str_a,"%d",QHeader.quest_number);
6767
6768 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6769
6770 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6771 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6772
6773 large_dialog(quest_dlg);
6774
6775 zc_popup_dialog(quest_dlg, 0);
6776 return D_O_K;
6777 }
6778
6779 void call_vidmode_dlg();
6780 int32_t onVidMode()
6781 {
6782 call_vidmode_dlg();
6783 return D_O_K;
6784 }
6785
6786 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6787 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6788 //Added an extra statement, so that if the key is cleared to 0, the cleared
6789 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6790
6791 void load_ukeys(int32_t* arr)
6792 {
6793 arr[ukey_a] = Akey;
6794 arr[ukey_b] = Bkey;
6795 arr[ukey_s] = Skey;
6796 arr[ukey_l] = Lkey;
6797 arr[ukey_r] = Rkey;
6798 arr[ukey_p] = Pkey;
6799 arr[ukey_ex1] = Exkey1;
6800 arr[ukey_ex2] = Exkey2;
6801 arr[ukey_ex3] = Exkey3;
6802 arr[ukey_ex4] = Exkey4;
6803 arr[ukey_du] = DUkey;
6804 arr[ukey_dd] = DDkey;
6805 arr[ukey_dl] = DLkey;
6806 arr[ukey_dr] = DRkey;
6807 arr[ukey_mod1a] = cheat_modifier_keys[0];
6808 arr[ukey_mod1b] = cheat_modifier_keys[1];
6809 arr[ukey_mod2a] = cheat_modifier_keys[2];
6810 arr[ukey_mod2b] = cheat_modifier_keys[3];
6811 };
6812
6813 static const char* ukey_names[] = {
6814 "A", "B", "Start", "L", "R", "Map",
6815 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6816 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6817 "Cheat Mod R1", "Cheat Mod R2",
6818 };
6819 std::string get_ukey_name(int32_t k)
6820 {
6821 if (k < num_ukey) return ukey_names[k];
6822 return "";
6823 }
6824
6825 int32_t onKeyboard()
6826 {
6827 int32_t a = Akey;
6828 int32_t b = Bkey;
6829 int32_t s = Skey;
6830 int32_t l = Lkey;
6831 int32_t r = Rkey;
6832 int32_t p = Pkey;
6833 int32_t ex1 = Exkey1;
6834 int32_t ex2 = Exkey2;
6835 int32_t ex3 = Exkey3;
6836 int32_t ex4 = Exkey4;
6837 int32_t du = DUkey;
6838 int32_t dd = DDkey;
6839 int32_t dl = DLkey;
6840 int32_t dr = DRkey;
6841 int32_t mod1a = cheat_modifier_keys[0];
6842 int32_t mod1b = cheat_modifier_keys[1];
6843 int32_t mod2a = cheat_modifier_keys[2];
6844 int32_t mod2b = cheat_modifier_keys[3];
6845 bool done=false;
6846 int32_t ret;
6847
6848 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6849
6850 large_dialog(keyboard_control_dlg);
6851
6852 while(!done)
6853 {
6854 ret = zc_popup_dialog(keyboard_control_dlg,3);
6855
6856 if(ret==3) // OK
6857 {
6858 int32_t ukeys[num_ukey];
6859 load_ukeys(ukeys);
6860 std::vector<std::string> uniqueError;
6861 for(int32_t q = 0; q < num_ukey; ++q)
6862 {
6863 for(int32_t p = q+1; p < num_ukey; ++p)
6864 {
6865 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6866 {
6867 char buf[64];
6868 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6869 std::string str(buf);
6870 uniqueError.push_back(str);
6871 }
6872 }
6873 }
6874 if(uniqueError.size() == 0)
6875 {
6876 done = true;
6877 save_control_configs(true);
6878 }
6879 else
6880 {
6881 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6882 box_out("Cannot have duplicate keybinds!"); box_eol();
6883 for(std::vector<std::string>::iterator it = uniqueError.begin();
6884 it != uniqueError.end(); ++it)
6885 {
6886 box_out((*it).c_str()); box_eol();
6887 }
6888 box_end(true);
6889 }
6890 }
6891 else // Cancel
6892 {
6893 Akey = a;
6894 Bkey = b;
6895 Skey = s;
6896 Lkey = l;
6897 Rkey = r;
6898 Pkey = p;
6899 Exkey1 = ex1;
6900 Exkey2 = ex2;
6901 Exkey3 = ex3;
6902 Exkey4 = ex4;
6903 DUkey = du;
6904 DDkey = dd;
6905 DLkey = dl;
6906 DRkey = dr;
6907 cheat_modifier_keys[0] = mod1a;
6908 cheat_modifier_keys[1] = mod1b;
6909 cheat_modifier_keys[2] = mod2a;
6910 cheat_modifier_keys[3] = mod2b;
6911
6912 done=true;
6913 }
6914
6915 rest(1);
6916 }
6917
6918 return D_O_K;
6919 }
6920
6921 int32_t onGamepad()
6922 {
6923 int32_t a = Abtn;
6924 int32_t b = Bbtn;
6925 int32_t s = Sbtn;
6926 int32_t l = Lbtn;
6927 int32_t r = Rbtn;
6928 int32_t m = Mbtn;
6929 int32_t p = Pbtn;
6930 int32_t ex1 = Exbtn1;
6931 int32_t ex2 = Exbtn2;
6932 int32_t ex3 = Exbtn3;
6933 int32_t ex4 = Exbtn4;
6934 int32_t up = DUbtn;
6935 int32_t down = DDbtn;
6936 int32_t left = DLbtn;
6937 int32_t right = DRbtn;
6938
6939 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6940 if(analog_movement)
6941 gamepad_dlg[56].flags|=D_SELECTED;
6942 else
6943 gamepad_dlg[56].flags&=~D_SELECTED;
6944
6945 large_dialog(gamepad_dlg);
6946
6947 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
6948
6949 if(ret == 4) //OK
6950 {
6951 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6952 save_control_configs(false);
6953 }
6954 else //Cancel
6955 {
6956 Abtn = a;
6957 Bbtn = b;
6958 Sbtn = s;
6959 Lbtn = l;
6960 Rbtn = r;
6961 Mbtn = m;
6962 Pbtn = p;
6963 Exbtn1 = ex1;
6964 Exbtn2 = ex2;
6965 Exbtn3 = ex3;
6966 Exbtn4 = ex4;
6967 DUbtn = up;
6968 DDbtn = down;
6969 DLbtn = left;
6970 DRbtn = right;
6971 }
6972
6973 return D_O_K;
6974 }
6975
6976 int32_t onCheatKeys()
6977 {
6978 int32_t oldcheats[Cheat::Last][2];
6979 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6980
6981 bool done=false;
6982
6983 while(!done)
6984 {
6985 bool confirm = false;
6986 CheatKeysDialog(&confirm).show();
6987 if(confirm) // OK
6988 {
6989 std::vector<std::string> uniqueError;
6990 char buf[512];
6991 for(size_t q = 1; q < Cheat::Last; ++q)
6992 {
6993 if(cheatkeys[q][1] && !cheatkeys[q][0])
6994 {
6995 cheatkeys[q][0] = cheatkeys[q][1];
6996 cheatkeys[q][1] = 0;
6997 }
6998 }
6999 for(size_t q = 1; q < Cheat::Last; ++q)
7000 {
7001 if(!bindable_cheat((Cheat)q)) continue;
7002 for(size_t p = q+1; p < Cheat::Last; ++p)
7003 {
7004 if(!bindable_cheat((Cheat)p)) continue;
7005 for(size_t q2 = 0; q2 <= 1; ++q2)
7006 for(size_t p2 = 0; p2 <= 1; ++p2)
7007 {
7008 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
7009 {
7010 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
7011 cheat_to_string((Cheat)q), q2?"Alt":"Main",
7012 cheat_to_string((Cheat)p), p2?"Alt":"Main",
7013 get_keystr(cheatkeys[q][q2])));
7014 }
7015 }
7016 }
7017 }
7018 if(uniqueError.size() == 0)
7019 {
7020 done = true;
7021 save_cheatkeys();
7022 }
7023 else
7024 {
7025 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
7026 box_out("Cannot have duplicate keybinds!"); box_eol();
7027 for(std::vector<std::string>::iterator it = uniqueError.begin();
7028 it != uniqueError.end(); ++it)
7029 {
7030 box_out((*it).c_str()); box_eol();
7031 }
7032 box_end(true);
7033 }
7034 }
7035 else // Cancel
7036 {
7037 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
7038 done=true;
7039 }
7040 rest(1);
7041 }
7042
7043 return D_O_K;
7044 }
7045
7046 int32_t onSound()
7047 {
7048 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
7049 {
7050 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
7051 }
7052 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
7053 {
7054 master_volume((int32_t)(FFCore.usr_digi_volume),1);
7055 }
7056 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
7057 {
7058 emusic_volume = (int32_t)FFCore.usr_music_volume;
7059 }
7060 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
7061 {
7062 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
7063 }
7064 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
7065 {
7066 pan_style = (int32_t)FFCore.usr_panstyle;
7067 }
7068
7069 int32_t m = midi_volume;
7070 int32_t d = digi_volume;
7071 int32_t e = emusic_volume;
7072 int32_t b = zcmusic_bufsz;
7073 int32_t s = sfx_volume;
7074 int32_t p = pan_style;
7075 pan_style = vbound(pan_style,0,3);
7076
7077 sound_dlg[0].dp2=get_zc_font(font_lfont);
7078
7079 large_dialog(sound_dlg);
7080
7081 midi_dp[1] = sound_dlg[6].x;
7082 midi_dp[2] = sound_dlg[6].y;
7083 digi_dp[1] = sound_dlg[7].x;
7084 digi_dp[2] = sound_dlg[7].y;
7085 emus_dp[1] = sound_dlg[8].x;
7086 emus_dp[2] = sound_dlg[8].y;
7087 buf_dp[1] = sound_dlg[9].x;
7088 buf_dp[2] = sound_dlg[9].y;
7089 sfx_dp[1] = sound_dlg[10].x;
7090 sfx_dp[2] = sound_dlg[10].y;
7091 pan_dp[1] = sound_dlg[11].x;
7092 pan_dp[2] = sound_dlg[11].y;
7093 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7094 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7095 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7096 sound_dlg[18].d2 = zcmusic_bufsz;
7097 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7098 sound_dlg[20].d2 = pan_style;
7099
7100 int32_t ret = zc_popup_dialog(sound_dlg,1);
7101
7102 if(ret==2)
7103 {
7104 master_volume(digi_volume,midi_volume);
7105
7106 for(int32_t i=0; i<WAV_COUNT; ++i)
7107 {
7108 //allegro assertion fails when passing in -1 as voice -DD
7109 if(sfx_voice[i] > 0)
7110 voice_set_volume(sfx_voice[i], sfx_volume);
7111 }
7112 zc_set_config(sfx_sect,"digi",digi_volume);
7113 zc_set_config(sfx_sect,"midi",midi_volume);
7114 zc_set_config(sfx_sect,"sfx",sfx_volume);
7115 zc_set_config(sfx_sect,"emusic",emusic_volume);
7116 zc_set_config(sfx_sect,"pan",pan_style);
7117 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
7118 }
7119 else
7120 {
7121 midi_volume = m;
7122 digi_volume = d;
7123 emusic_volume = e;
7124 zcmusic_bufsz = b;
7125 sfx_volume = s;
7126 pan_style = p;
7127 }
7128
7129 return D_O_K;
7130 }
7131
7132 int32_t queding(char const* s1, char const* s2, char const* s3)
7133 {
7134 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
7135 }
7136
7137 int32_t onQuit()
7138 {
7139 if(Playing)
7140 {
7141 int32_t ret=0;
7142
7143 if(get_bit(quest_rules, qr_NOCONTINUE))
7144 {
7145 if(standalone_mode)
7146 {
7147 ret=queding("End current game?",
7148 "The continue screen is disabled; the game",
7149 "will be reloaded from the last save.");
7150 }
7151 else
7152 {
7153 ret=queding("End current game?",
7154 "The continue screen is disabled. You will",
7155 "be returned to the file select screen.");
7156 }
7157 }
7158 else
7159 ret=queding("End current game?",NULL,NULL);
7160
7161 if(ret==1)
7162 {
7163 disableClickToFreeze=false;
7164 Quit=qQUIT;
7165
7166 // Trying to evade a door repair charge?
7167 if(repaircharge)
7168 {
7169 game->change_drupy(-repaircharge);
7170 repaircharge=0;
7171 }
7172
7173 return D_CLOSE;
7174 }
7175 }
7176
7177 return D_O_K;
7178 }
7179
7180 int32_t onTryQuitMenu()
7181 {
7182 return onTryQuit(true);
7183 }
7184
7185 int32_t onTryQuit(bool inMenu)
7186 {
7187 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7188 {
7189 if(active_cutscene.can_f6())
7190 {
7191 if(get_bit(quest_rules,qr_OLD_F6))
7192 {
7193 if(inMenu) onQuit();
7194 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7195 }
7196 else
7197 {
7198 disableClickToFreeze=false;
7199 GameFlags |= GAMEFLAG_TRYQUIT;
7200 }
7201 return D_CLOSE;
7202 }
7203 else active_cutscene.error();
7204 }
7205
7206 return D_O_K;
7207 }
7208
7209 int32_t onReset()
7210 {
7211 if(queding(" Reset system? ",NULL,NULL)==1)
7212 {
7213 disableClickToFreeze=false;
7214 Quit=qRESET;
7215 replay_quit();
7216 return D_CLOSE;
7217 }
7218
7219 return D_O_K;
7220 }
7221
7222 int32_t onExit()
7223 {
7224 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7225 {
7226 Quit=qEXIT;
7227 return D_CLOSE;
7228 }
7229
7230 return D_O_K;
7231 }
7232
7233 int32_t onTitle_NES()
7234 {
7235 title_version=0;
7236 zc_set_config(cfg_sect,"title",title_version);
7237 return D_O_K;
7238 }
7239 int32_t onTitle_DX()
7240 {
7241 title_version=1;
7242 zc_set_config(cfg_sect,"title",title_version);
7243 return D_O_K;
7244 }
7245 int32_t onTitle_25()
7246 {
7247 title_version=2;
7248 zc_set_config(cfg_sect,"title",title_version);
7249 return D_O_K;
7250 }
7251
7252 int32_t onDebug()
7253 {
7254 if(debug_enabled)
7255 set_debug(!get_debug());
7256 return D_O_K;
7257 }
7258
7259 int32_t onHeartBeep()
7260 {
7261 heart_beep=!heart_beep;
7262 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7263 return D_O_K;
7264 }
7265
7266 int32_t onSaveIndicator()
7267 {
7268 use_save_indicator=!use_save_indicator;
7269 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7270 return D_O_K;
7271 }
7272
7273 int32_t onEpilepsy()
7274 {
7275 if(jwin_alert3(
7276 "Epilepsy Flash Reduction",
7277 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7278 "Disabling this will restore standard flash and wavy behaviour.",
7279 "Proceed?",
7280 "&Yes",
7281 "&No",
7282 NULL,
7283 'y',
7284 'n',
7285 0,
7286 get_zc_font(font_lfont)) == 1)
7287 {
7288 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7289 zc_set_config("zeldadx","checked_epilepsy",1);
7290 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7291 }
7292 return D_O_K;
7293 }
7294
7295 int32_t onTriforce()
7296 {
7297 for(int32_t i=0; i<MAXINITTABS; ++i)
7298 {
7299 init_tabs[i].flags&=~D_SELECTED;
7300 }
7301
7302 init_tabs[3].flags=D_SELECTED;
7303 return onCheatConsole();
7304 /*triforce_dlg[0].dp2=get_zc_font(font_lfont);
7305 for(int32_t i=1; i<=8; i++)
7306 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7307
7308 if(zc_popup_dialog (triforce_dlg,-1)==9)
7309 {
7310 for(int32_t i=1; i<=8; i++)
7311 {
7312 game->lvlitems[i] &= ~liTRIFORCE;
7313 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7314 }
7315 }
7316 return D_O_K;*/
7317 }
7318
7319 bool rc = false;
7320 /*
7321 int32_t onEquipment()
7322 {
7323 for (int32_t i=0; i<MAXINITTABS; ++i)
7324 {
7325 init_tabs[i].flags&=~D_SELECTED;
7326 }
7327 init_tabs[0].flags=D_SELECTED;
7328 return onCheatConsole();
7329 }
7330 */
7331
7332 int32_t onItems()
7333 {
7334 for(int32_t i=0; i<MAXINITTABS; ++i)
7335 {
7336 init_tabs[i].flags&=~D_SELECTED;
7337 }
7338
7339 init_tabs[1].flags=D_SELECTED;
7340 return onCheatConsole();
7341 }
7342
7343 static DIALOG getnum_dlg[] =
7344 {
7345 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7346 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7347 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7348 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7349 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7350 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7351 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7352 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7353 };
7354
7355 int32_t getnumber(const char *prompt,int32_t initialval)
7356 {
7357 char buf[20];
7358 sprintf(buf,"%d",initialval);
7359 getnum_dlg[0].dp=(void *)prompt;
7360 getnum_dlg[0].dp2=get_zc_font(font_lfont);
7361 getnum_dlg[2].dp=buf;
7362
7363 large_dialog(getnum_dlg);
7364
7365 if(zc_popup_dialog(getnum_dlg,2)==3)
7366 return atoi(buf);
7367
7368 return initialval;
7369 }
7370
7371 int32_t onLife()
7372 {
7373 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7374 cheats_enqueue(Cheat::Life, value);
7375 return D_O_K;
7376 }
7377
7378 int32_t onHeartC()
7379 {
7380 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7381 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7382 cheats_enqueue(Cheat::MaxLife, max_life);
7383 cheats_enqueue(Cheat::Life, life);
7384 return D_O_K;
7385 }
7386
7387 int32_t onMagicC()
7388 {
7389 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7390 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7391 cheats_enqueue(Cheat::MaxMagic, max_magic);
7392 cheats_enqueue(Cheat::Magic, magic);
7393 return D_O_K;
7394 }
7395
7396 int32_t onRupies()
7397 {
7398 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7399 cheats_enqueue(Cheat::Rupies, value);
7400 return D_O_K;
7401 }
7402
7403 int32_t onMaxBombs()
7404 {
7405 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7406 cheats_enqueue(Cheat::MaxBombs, value);
7407 cheats_enqueue(Cheat::Bombs, value);
7408 return D_O_K;
7409 }
7410
7411 int32_t onRefillLife()
7412 {
7413 cheats_enqueue(Cheat::Life, game->get_maxlife());
7414 return D_O_K;
7415 }
7416 int32_t onRefillMagic()
7417 {
7418 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7419 return D_O_K;
7420 }
7421 int32_t onClock()
7422 {
7423 cheats_enqueue(Cheat::Clock);
7424 return D_O_K;
7425 }
7426
7427 int32_t onQstPath()
7428 {
7429 char path[2048];
7430
7431 chop_path(qstdir);
7432 strcpy(path,qstdir);
7433
7434 go();
7435
7436 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, get_zc_font(font_lfont)))
7437 {
7438 chop_path(path);
7439 fix_filename_case(path);
7440 fix_filename_slashes(path);
7441 strcpy(qstdir,path);
7442 strcpy(qstpath,qstdir);
7443 }
7444
7445 comeback();
7446 return D_O_K;
7447 }
7448
7449 #include "dialog/cheat_dialog.h"
7450 int32_t onCheat()
7451 {
7452 call_setcheat_dialog();
7453 game->set_cheat(maxcheat);
7454 if(cheat) game->did_cheat(true);
7455 return D_O_K;
7456 }
7457
7458 int32_t onCheatRupies()
7459 {
7460 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7461 return D_O_K;
7462 }
7463
7464 int32_t onCheatArrows()
7465 {
7466 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7467 return D_O_K;
7468 }
7469
7470 int32_t onCheatBombs()
7471 {
7472 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7473 return D_O_K;
7474 }
7475
7476 // *** screen saver
7477
7478 7521864 int32_t after_time()
7479 {
7480
1/2
✓ Branch 0 taken 7521864 times.
✗ Branch 1 not taken.
7521864 if(ss_enable == 0)
7481 return INT_MAX;
7482
7483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7521864 times.
7521864 if(ss_after <= 0)
7484 return 5 * 60;
7485
7486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7521864 times.
7521864 if(ss_after <= 3)
7487 return ss_after * 15 * 60;
7488
7489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7521864 times.
7521864 if(ss_after <= 13)
7490 return (ss_after - 3) * 60 * 60;
7491
7492 7521864 return MAX_IDLE + 1;
7493 7521864 }
7494
7495 static const char *after_str[15] =
7496 {
7497 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7498 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7499 "Never"
7500 };
7501
7502 const char *after_list(int32_t index, int32_t *list_size)
7503 {
7504 if(index < 0)
7505 {
7506 *list_size = 15;
7507 return NULL;
7508 }
7509
7510 return after_str[index];
7511 }
7512
7513 31 static ListData after__list(after_list, &font);
7514
7515 static DIALOG scrsaver_dlg[] =
7516 {
7517 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7518 31 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7519 31 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7520 31 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7521 31 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7522 31 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7523 31 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7524 31 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7525 31 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7526 31 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7527 31 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7528 31 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7529 31 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7530 31 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7531 };
7532
7533 int32_t onScreenSaver()
7534 {
7535 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7536 int32_t oldcfgs[3];
7537 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7538 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7539 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7540
7541 large_dialog(scrsaver_dlg);
7542
7543 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7544
7545 if(ret == 8 || ret == 9)
7546 {
7547 ss_after = scrsaver_dlg[5].d1;
7548 ss_speed = scrsaver_dlg[6].d2;
7549 ss_density = scrsaver_dlg[7].d2;
7550 if(oldcfgs[0] != ss_after)
7551 zc_set_config(cfg_sect,"ss_after",ss_after);
7552 if(oldcfgs[1] != ss_speed)
7553 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7554 if(oldcfgs[2] != ss_density)
7555 zc_set_config(cfg_sect,"ss_density",ss_density);
7556 }
7557
7558 if(ret == 9)
7559 // preview Screen Saver
7560 {
7561 clear_keybuf();
7562 Matrix(ss_speed, ss_density, 30);
7563 system_pal();
7564 }
7565
7566 return D_O_K;
7567 }
7568
7569 /***** Menus *****/
7570
7571 static MENU game_menu[] =
7572 {
7573 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7574 { (char *)"", NULL, NULL, 0, NULL },
7575 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7576 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7577 { (char *)"", NULL, NULL, 0, NULL },
7578 #ifdef __EMSCRIPTEN__
7579 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7580 #elif defined(ALLEGRO_MACOSX)
7581 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7582 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7583 #else
7584 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7585 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7586 #endif
7587 { NULL, NULL, NULL, 0, NULL }
7588 };
7589
7590 static MENU title_menu[] =
7591 {
7592 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7593 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7594 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7595 { NULL, NULL, NULL, 0, NULL }
7596 };
7597
7598 static MENU snapshot_format_menu[] =
7599 {
7600 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7601 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7602 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7603 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7604 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7605 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7606 { NULL, NULL, NULL, 0, NULL }
7607 };
7608
7609 static MENU controls_menu[] =
7610 {
7611 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7612 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7613 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7614 { NULL, NULL, NULL, 0, NULL }
7615 };
7616
7617 static MENU name_entry_mode_menu[] =
7618 {
7619 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7620 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7621 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7622 { NULL, NULL, NULL, 0, NULL }
7623 };
7624
7625 static void set_controls_menu_active()
7626 {
7627
7628 }
7629
7630 static MENU window_menu[] =
7631 {
7632 { "Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7633 { "Lock Integer Scale", onIntegerScaling, NULL, 0, NULL },
7634 { "Save Size Changes", onSaveDragResize, NULL, 0, NULL },
7635 { "Save Position Changes", onWinPosSave, NULL, 0, NULL },
7636 { "Stretch Game Area", onStretchGame, NULL, 0, NULL },
7637 { NULL, NULL, NULL, 0, NULL }
7638 };
7639 static MENU options_menu[] =
7640 {
7641 { "&Title Screen", NULL, title_menu, 0, NULL },
7642 { "Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7643 { "S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7644 { "&Window Settings", NULL, window_menu, 0, NULL },
7645 { "Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7646 { "Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
7647 { NULL, NULL, NULL, 0, NULL }
7648 };
7649 static MENU settings_menu[] =
7650 {
7651 { "&Sound...", onSound, NULL, 0, NULL },
7652 { "C&ontrols", NULL, controls_menu, 0, NULL },
7653 { "", NULL, NULL, 0, NULL },
7654 { "Options", NULL, options_menu, 0, NULL },
7655 { "", NULL, NULL, 0, NULL },
7656 //
7657 { "&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7658 { "Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7659 { "Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7660 { "Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7661 { "Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7662 //
7663 { "Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7664 { "Volume &Keys", onVolKeys, NULL, 0, NULL },
7665 { "Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7666 { "", NULL, NULL, 0, NULL },
7667 { "Debu&g", onDebug, NULL, 0, NULL },
7668 //
7669 { NULL, NULL, NULL, 0, NULL }
7670 };
7671
7672
7673 static MENU misc_menu[] =
7674 {
7675 { (char *)"&About...", onAbout, NULL, 0, NULL },
7676 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7677 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7678 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7679 { (char *)"", NULL, NULL, 0, NULL },
7680 //5
7681 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7682 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7683 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7684 { (char *)"", NULL, NULL, 0, NULL },
7685 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7686 //10
7687 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7688 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7689 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7690 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7691 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7692 //15
7693 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7694 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7695 { NULL, NULL, NULL, 0, NULL }
7696 };
7697
7698 static MENU refill_menu[] =
7699 {
7700 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7701 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7702 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7703 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7704 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7705 { NULL, NULL, NULL, 0, NULL }
7706 };
7707
7708 static MENU show_menu[] =
7709 {
7710 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7711 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7712 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7713 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7714 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7715 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7716 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7717 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7718 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7719 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7720 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7721 { (char *)"", NULL, NULL, 0, NULL },
7722 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7723 { (char *)"", NULL, NULL, 0, NULL },
7724 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7725 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7726 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7727 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7728 { NULL, NULL, NULL, 0, NULL }
7729 };
7730
7731 static MENU cheat_menu[] =
7732 {
7733 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7734 { (char *)"", NULL, NULL, 0, NULL },
7735 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7736 { (char *)"", NULL, NULL, 0, NULL },
7737 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7738 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7739 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7740 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7741 { (char *)"", NULL, NULL, 0, NULL },
7742 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7743 { (char *)"", NULL, NULL, 0, NULL },
7744 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7745 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7746 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7747 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7748 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7749 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7750 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7751 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7752 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7753 { NULL, NULL, NULL, 0, NULL }
7754 };
7755
7756 #if DEVLEVEL > 0
7757 int32_t devLogging();
7758 int32_t devDebug();
7759 int32_t devTimestmp();
7760 #if DEVLEVEL > 1
7761 int32_t setCheat();
7762 #endif //DEVLEVEL > 1
7763 enum
7764 {
7765 dv_log,
7766 // dv_dbg,
7767 dv_tmpstmp,
7768 #if DEVLEVEL > 1
7769 dv_nil,
7770 dv_setcheat,
7771 #endif //DEVLEVEL > 1
7772 dv_max
7773 };
7774 static MENU dev_menu[] =
7775 {
7776 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7777 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7778 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7779 #if DEVLEVEL > 1
7780 { (char *)"", NULL, NULL, 0, NULL },
7781 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7782 #endif //DEVLEVEL > 1
7783 { NULL, NULL, NULL, 0, NULL }
7784 };
7785 int32_t devLogging()
7786 {
7787 dev_logging = !dev_logging;
7788 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7789 return D_O_K;
7790 }
7791 // int32_t devDebug()
7792 // {
7793 // dev_debug = !dev_debug;
7794 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7795 // return D_O_K;
7796 // }
7797 int32_t devTimestmp()
7798 {
7799 dev_timestmp = !dev_timestmp;
7800 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7801 return D_O_K;
7802 }
7803 #if DEVLEVEL > 1
7804 int32_t setCheat()
7805 {
7806 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7807 return D_O_K;
7808 }
7809 #endif //DEVLEVEL > 1
7810 #endif //DEVLEVEL > 0
7811
7812 MENU the_player_menu[] =
7813 {
7814 { (char *)"&Game", NULL, game_menu, 0, NULL },
7815 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7816 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7817 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7818 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7819 #if DEVLEVEL > 0
7820 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7821 #endif
7822 { NULL, NULL, NULL, 0, NULL }
7823 };
7824 int32_t onMIDIPatch()
7825 {
7826 if(jwin_alert3(
7827 "Toggle Windows MIDI Fix",
7828 "This action will change whether ZC Player auto-restarts a MIDI at its",
7829 "last index if you move ZC Player out of focus, then back into focus.",
7830 "Proceed?",
7831 "&Yes",
7832 "&No",
7833 NULL,
7834 'y',
7835 'n',
7836 0,
7837 get_zc_font(font_lfont)) == 1)
7838 {
7839 midi_patch_fix = midi_patch_fix ? 0 : 1;
7840 zc_set_config("zeldadx","midi_patch_fix",midi_patch_fix);
7841 }
7842 options_menu[5].flags =(midi_patch_fix)?D_SELECTED:0;
7843 return D_O_K;
7844 }
7845
7846 int32_t onKeyboardEntry()
7847 {
7848 NameEntryMode=0;
7849 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7850 return D_O_K;
7851 }
7852
7853 int32_t onLetterGridEntry()
7854 {
7855 NameEntryMode=1;
7856 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7857 return D_O_K;
7858 }
7859
7860 int32_t onExtLetterGridEntry()
7861 {
7862 NameEntryMode=2;
7863 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7864 return D_O_K;
7865 }
7866
7867 static BITMAP* oldscreen;
7868 int32_t onFullscreenMenu()
7869 {
7870 // super hacks
7871 screen = oldscreen;
7872 if (onFullscreen() == D_REDRAW)
7873 {
7874 oldscreen = screen;
7875 }
7876 screen = menu_bmp;
7877 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7878 return D_O_K;
7879 }
7880
7881 31 void fix_menu()
7882 {
7883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(!debug_enabled)
7884 31 settings_menu[13].text = NULL;
7885 31 }
7886
7887 static DIALOG system_dlg[] =
7888 {
7889 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7890 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7891 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7892 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7893 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7894 #ifndef ALLEGRO_MACOSX
7895 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7896 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7897 #else
7898 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7899 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7900 #endif
7901 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7902 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7903 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7904 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7905 };
7906
7907 void reset_snapshot_format_menu()
7908 {
7909 for(int32_t i=0; i<ssfmtMAX; ++i)
7910 {
7911 snapshot_format_menu[i].flags=0;
7912 }
7913 }
7914
7915 int32_t onSetSnapshotFormat()
7916 {
7917 switch(active_menu->text[1])
7918 {
7919 case 'B': //"&BMP"
7920 SnapshotFormat=0;
7921 break;
7922
7923 case 'G': //"&GIF"
7924 SnapshotFormat=1;
7925 break;
7926
7927 case 'J': //"&JPG"
7928 SnapshotFormat=2;
7929 break;
7930
7931 case 'P': //"&PNG"
7932 SnapshotFormat=3;
7933 break;
7934
7935 case 'C': //"PC&X"
7936 SnapshotFormat=4;
7937 break;
7938
7939 case 'T': //"&TGA"
7940 SnapshotFormat=5;
7941 break;
7942
7943 case 'L': //"&LBM"
7944 SnapshotFormat=6;
7945 break;
7946 }
7947 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7948
7949 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7950 return D_O_K;
7951 }
7952
7953
7954 45 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7955 {
7956 PALETTE tmp;
7957
7958
2/2
✓ Branch 0 taken 11520 times.
✓ Branch 1 taken 45 times.
11565 for(int32_t i=0; i<256; i++)
7959 {
7960 11520 tmp[i].r=r;
7961 11520 tmp[i].g=g;
7962 11520 tmp[i].b=b;
7963 11520 }
7964
7965 45 fade_interpolate(src,tmp,dest,pos,from,to);
7966 45 }
7967
7968 45 void system_pal()
7969 {
7970 45 is_sys_pal = true;
7971 static PALETTE pal;
7972 45 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
7973
7974 // set up the grayscale palette
7975
2/2
✓ Branch 0 taken 2880 times.
✓ Branch 1 taken 45 times.
2925 for(int32_t i=128; i<192; i++)
7976 {
7977 2880 pal[i].r = i-128;
7978 2880 pal[i].g = i-128;
7979 2880 pal[i].b = i-128;
7980 2880 }
7981 45 load_colorset(gui_colorset, pal, jwin_a5_colors);
7982
7983 45 color_layer(pal, pal, 24,16,16, 28, 128,191);
7984
7985
2/2
✓ Branch 0 taken 5760 times.
✓ Branch 1 taken 45 times.
5805 for(int32_t i=0; i<256; i+=2)
7986 {
7987 5760 int32_t v = (i>>3)+2;
7988 5760 int32_t c = (i>>3)+192;
7989 5760 pal[c] = _RGB(v,v,v+(v>>1));
7990 /*
7991 if(i<240)
7992 {
7993 _allegro_hline(tmp_scr,0,i,319,c);
7994 _allegro_hline(tmp_scr,0,i+1,319,c);
7995 }
7996 */
7997 5760 }
7998
7999 // draw the vertical screen gradient
8000
2/2
✓ Branch 0 taken 10800 times.
✓ Branch 1 taken 45 times.
10845 for(int32_t i=0; i<240; ++i)
8001 {
8002 10800 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8003 10800 }
8004
8005 /*
8006 palrstart= 10*63/255; palrend=166*63/255;
8007 palgstart= 36*63/255; palgend=202*63/255;
8008 palbstart=106*63/255; palbend=240*63/255;
8009 paldivs=32;
8010 for(int32_t i=0; i<paldivs; i++)
8011 {
8012 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8013 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8014 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8015 }
8016 */
8017 45 BITMAP *panorama = create_bitmap_ex(8,256,224);
8018 int32_t ts_height, ts_start;
8019
8020
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
45 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8021 {
8022 clear_to_color(panorama,0);
8023 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8024 ts_height=224-passive_subscreen_height;
8025 ts_start=28;
8026 }
8027 else
8028 {
8029 45 blit(framebuf,panorama,0,0,0,0,256,224);
8030 45 ts_height=224;
8031 45 ts_start=0;
8032 }
8033
8034 // gray scale the current frame
8035
2/2
✓ Branch 0 taken 10080 times.
✓ Branch 1 taken 45 times.
10125 for(int32_t y=0; y<ts_height; y++)
8036 {
8037
2/2
✓ Branch 0 taken 2580480 times.
✓ Branch 1 taken 10080 times.
2590560 for(int32_t x=0; x<256; x++)
8038 {
8039 2580480 int32_t c = panorama->line[y+ts_start][x];
8040
2/2
✓ Branch 0 taken 2574590 times.
✓ Branch 1 taken 5890 times.
2580480 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
8041 2580480 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8042 2580480 }
8043 10080 }
8044
8045 45 destroy_bitmap(panorama);
8046
8047 // display everything
8048 45 vsync();
8049 45 hw_palette = &pal;
8050 45 update_hw_pal = true;
8051
8052 // sys_pal = pal;
8053 45 memcpy(sys_pal,pal,sizeof(pal));
8054 45 }
8055
8056 void system_pal2()
8057 {
8058 is_sys_pal = true;
8059 static PALETTE RAMpal2;
8060 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
8061
8062 /* Windows 2000 colors
8063 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8064 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
8065 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
8066 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
8067 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8068 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8069 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8070 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8071
8072 byte palrstart= 10*63/255, palrend=166*63/255,
8073 palgstart= 36*63/255, palgend=202*63/255,
8074 palbstart=106*63/255, palbend=240*63/255,
8075 paldivs=7;
8076 for(int32_t i=0; i<paldivs; i++)
8077 {
8078 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8079 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8080 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8081 }
8082 */
8083
8084 /* Windows 98 colors
8085 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8086 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8087 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8088 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8089 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8090 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8091 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8092 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8093
8094 byte palrstart= 0*63/255, palrend=166*63/255,
8095 palgstart= 0*63/255, palgend=202*63/255,
8096 palbstart=128*63/255, palbend=240*63/255,
8097 paldivs=7;
8098 for(int32_t i=0; i<paldivs; i++)
8099 {
8100 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8101 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8102 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8103 }
8104 */
8105
8106 /* Windows 99 colors
8107 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8108 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8109 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8110 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8111 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8112 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8113 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8114 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8115 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8116
8117 byte palrstart= 0*63/255, palrend=166*63/255,
8118 palgstart= 0*63/255, palgend=202*63/255,
8119
8120 palbstart=128*63/255, palbend=240*63/255,
8121 paldivs=6;
8122 for(int32_t i=0; i<paldivs; i++)
8123 {
8124 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8125 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8126 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8127 }
8128 */
8129
8130
8131
8132 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8133 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8134 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8135 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8136 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8137 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8138 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8139 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8140 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8141
8142 byte palrstart= 0*63/255, palrend=166*63/255,
8143 palgstart= 0*63/255, palgend=202*63/255,
8144 palbstart=128*63/255, palbend=240*63/255,
8145 paldivs=6;
8146
8147 for(int32_t i=0; i<paldivs; i++)
8148 {
8149 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8150 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8151 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8152 }
8153
8154 gui_bg_color=jwin_pal[jcBOX];
8155 gui_fg_color=jwin_pal[jcBOXFG];
8156
8157 jwin_set_colors(jwin_pal);
8158
8159
8160 // set up the new palette
8161 for(int32_t i=128; i<192; i++)
8162 {
8163 RAMpal2[i].r = i-128;
8164 RAMpal2[i].g = i-128;
8165 RAMpal2[i].b = i-128;
8166 }
8167
8168 /*
8169 for(int32_t i=0; i<64; i++)
8170 {
8171 RAMpal2[128+i] = _RGB(i,i,i)1));
8172 }
8173 */
8174
8175 /*
8176
8177 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8178 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8179 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8180 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8181 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8182 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8183 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8184
8185 gui_fg_color=vc(14);
8186 gui_bg_color=vc(1);
8187
8188 jwin_set_colors(jwin_pal);
8189 */
8190
8191 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8192
8193 // set up the colors for the vertical screen gradient
8194 for(int32_t i=0; i<256; i+=2)
8195 {
8196 int32_t v = (i>>3)+2;
8197 int32_t c = (i>>3)+192;
8198 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8199
8200 /*
8201 if(i<240)
8202 {
8203 _allegro_hline(tmp_scr,0,i,319,c);
8204 _allegro_hline(tmp_scr,0,i+1,319,c);
8205 }
8206 */
8207 }
8208
8209 // hw_palette = &RAMpal;
8210 // update_hw_pal = true;
8211
8212 for(int32_t i=0; i<240; ++i)
8213 {
8214 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8215 }
8216
8217 /*
8218 byte palrstart= 10*63/255, palrend=166*63/255,
8219 palgstart= 36*63/255, palgend=202*63/255,
8220 palbstart=106*63/255, palbend=240*63/255,
8221 paldivs=32;
8222 for(int32_t i=0; i<paldivs; i++)
8223 {
8224 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8225 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8226 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8227 }
8228 */
8229 BITMAP *panorama = create_bitmap_ex(8,256,224);
8230 int32_t ts_height, ts_start;
8231
8232 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8233 {
8234 clear_to_color(panorama,0);
8235 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8236 ts_height=224-passive_subscreen_height;
8237 ts_start=28;
8238 }
8239 else
8240 {
8241 blit(framebuf,panorama,0,0,0,0,256,224);
8242 ts_height=224;
8243 ts_start=0;
8244 }
8245
8246 // gray scale the current frame
8247 for(int32_t y=0; y<ts_height; y++)
8248 {
8249 for(int32_t x=0; x<256; x++)
8250 {
8251 int32_t c = panorama->line[y+ts_start][x];
8252 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8253 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8254 }
8255 }
8256
8257 destroy_bitmap(panorama);
8258
8259 // display everything
8260 vsync();
8261 hw_palette = &RAMpal2;
8262 update_hw_pal = true;
8263
8264 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8265
8266 // sys_pal = pal;
8267 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8268 }
8269
8270 static uint32_t entered_sys_pal = 0;
8271 14 void enter_sys_pal()
8272 {
8273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
8274 {
8275 if(entered_sys_pal)
8276 ++entered_sys_pal;
8277 return;
8278 }
8279 14 system_pal();
8280 14 ++entered_sys_pal;
8281 14 }
8282 14 void exit_sys_pal()
8283 {
8284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
8285 {
8286
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
8287 {
8288 14 game_pal();
8289 14 }
8290 14 }
8291 14 }
8292
8293 void switch_out_callback()
8294 {
8295 if (pause_in_background)
8296 {
8297 callback_switchin = 3;
8298 return;
8299 }
8300
8301 #ifdef _WIN32
8302 if(midi_patch_fix==0 || currmidi==-1)
8303 return;
8304
8305
8306 paused_midi_pos = midi_pos;
8307 zc_stop_midi();
8308 midi_paused=true;
8309 midi_suspended = midissuspHALTED;
8310 #endif
8311 }
8312
8313 void switch_in_callback()
8314 {
8315 if(pause_in_background)
8316 {
8317 return;
8318 }
8319
8320 #ifdef _WIN32
8321 if(midi_patch_fix==0 || currmidi==-1)
8322 return;
8323
8324 else
8325 {
8326 callback_switchin = 1;
8327 midi_suspended = midissuspRESUME;
8328 }
8329 #endif
8330 }
8331
8332 279 void game_pal()
8333 {
8334 279 is_sys_pal = false;
8335 279 entered_sys_pal = 0;
8336 279 clear_to_color(screen,BLACK);
8337 279 hw_palette = &RAMpal;
8338 279 update_hw_pal = true;
8339 279 }
8340
8341 static char bar_str[] = "";
8342
8343 14 void music_pause()
8344 {
8345 //al_pause_duh(tmplayer);
8346 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
8347 14 zc_midi_pause();
8348 14 midi_paused=true;
8349 14 }
8350
8351 void music_resume()
8352 {
8353 //al_resume_duh(tmplayer);
8354 zcmusic_pause(zcmusic, ZCM_RESUME);
8355 zc_midi_resume();
8356 midi_paused=false;
8357 }
8358
8359 5912 void music_stop()
8360 {
8361 //al_stop_duh(tmplayer);
8362 //unload_duh(tmusic);
8363 //tmusic=NULL;
8364 //tmplayer=NULL;
8365 5912 zcmusic_stop(zcmusic);
8366 5912 zcmusic_unload_file(zcmusic);
8367 5912 zc_stop_midi();
8368 5912 midi_paused=false;
8369 5912 currmidi=-1;
8370 5912 }
8371
8372 void System()
8373 {
8374 mouse_down=gui_mouse_b();
8375 music_pause();
8376 pause_all_sfx();
8377 MenuOpen = true;
8378 system_pal();
8379 // FONT *oldfont=font;
8380 // font=tfont;
8381
8382 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8383 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8384
8385 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8386 #if DEVLEVEL > 1
8387 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
8388 #endif
8389 game_menu[3].flags =
8390 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8391 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8392 clear_keybuf();
8393 sys_mouse();
8394
8395 DIALOG_PLAYER *p;
8396
8397 clear_bitmap(menu_bmp);
8398 oldscreen = screen;
8399 screen = menu_bmp;
8400
8401 p = init_dialog(system_dlg,-1);
8402
8403 // drop the menu on startup if menu button pressed
8404 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8405 simulate_keypress(KEY_G << 8);
8406
8407 do
8408 {
8409 if(close_button_quit)
8410 {
8411 close_button_quit = false;
8412 f_Quit(qEXIT);
8413 if(Quit) break;
8414 }
8415 rest(17);
8416
8417 if(mouse_down && !gui_mouse_b())
8418 mouse_down=0;
8419
8420 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8421 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8422 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8423
8424 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
8425 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8426 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8427 settings_menu[7].flags = ClickToFreeze?D_SELECTED:0;
8428 settings_menu[9].flags = TransLayers?D_SELECTED:0;
8429 settings_menu[10].flags = NESquit?D_SELECTED:0;
8430 settings_menu[11].flags = volkeys?D_SELECTED:0;
8431
8432 window_menu[0].flags = DragAspect?D_SELECTED:0;
8433 window_menu[1].flags = scaleForceInteger?D_SELECTED:0;
8434 window_menu[2].flags = SaveDragResize?D_SELECTED:0;
8435 window_menu[3].flags = SaveWinPos?D_SELECTED:0;
8436 window_menu[4].flags = stretchGame?D_SELECTED:0;
8437
8438 options_menu[4].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8439 options_menu[5].flags = (midi_patch_fix)?D_SELECTED:0;
8440
8441 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8442 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8443 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8444
8445 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8446 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8447 misc_menu[14].flags =(clearConsoleOnReload)?D_SELECTED:0;
8448 misc_menu[15].flags =(clearConsoleOnLoad)?D_SELECTED:0;
8449
8450 bool nocheat = (replay_is_replaying() || !Playing
8451 || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
8452 the_player_menu[2].flags = nocheat ? D_DISABLED : 0;
8453 cheat_menu[0].flags = 0;
8454 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8455 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8456 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8457 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8458 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8459 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8460 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8461 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8462 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8463
8464 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8465 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8466 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8467 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8468 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8469 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8470 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8471 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8472 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8473 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8474 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8475 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8476 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8477 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8478 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8479
8480 settings_menu[8].flags = heart_beep ? D_SELECTED : 0;
8481 settings_menu[12].flags = use_save_indicator ? D_SELECTED : 0;
8482
8483 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8484 (char *)"Disable recording new saves" :
8485 (char *)"Enable recording new saves";
8486 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8487 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8488 (char *)"Stop recording" :
8489 (char *)"Stop replaying";
8490 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8491 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8492 (char *)"Disable snapshot all frames" :
8493 (char *)"Enable snapshot all frames";
8494
8495 reset_snapshot_format_menu();
8496 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8497
8498 if(debug_enabled)
8499 {
8500 settings_menu[14].flags = get_debug() ? D_SELECTED : 0;
8501 }
8502
8503 if(gui_mouse_b() && !mouse_down)
8504 break;
8505
8506 // press menu to drop the menu
8507 if(rMbtn())
8508 simulate_keypress(KEY_G << 8);
8509
8510 if(input_idle(true) > after_time())
8511 // run Screeen Saver
8512 {
8513 // Screen saver enabled for now.
8514 clear_keybuf();
8515 Matrix(ss_speed, ss_density, 0);
8516 system_pal();
8517 broadcast_dialog_message(MSG_DRAW, 0);
8518 }
8519
8520 update_hw_screen();
8521 }
8522 while(update_dialog(p));
8523
8524 screen = oldscreen;
8525
8526 // font=oldfont;
8527 mouse_down=gui_mouse_b();
8528 shutdown_dialog(p);
8529 game_mouse();
8530 MenuOpen = false;
8531 if(Quit)
8532 {
8533 kill_sfx();
8534 music_stop();
8535 update_hw_screen();
8536 }
8537 else
8538 {
8539 game_pal();
8540 music_resume();
8541 resume_all_sfx();
8542
8543 if(rc)
8544 ringcolor(false);
8545 }
8546
8547 eat_buttons();
8548
8549 rc=false;
8550 clear_keybuf();
8551 // text_mode(0);
8552 }
8553
8554 31 void fix_dialogs()
8555 {
8556 31 jwin_center_dialog(about_dlg);
8557 31 jwin_center_dialog(gamepad_dlg);
8558 31 jwin_center_dialog(credits_dlg);
8559 31 jwin_center_dialog(gamemode_dlg);
8560 31 jwin_center_dialog(getnum_dlg);
8561 31 jwin_center_dialog(goto_dlg);
8562 31 jwin_center_dialog(keyboard_control_dlg);
8563 31 jwin_center_dialog(midi_dlg);
8564 31 jwin_center_dialog(quest_dlg);
8565 31 jwin_center_dialog(scrsaver_dlg);
8566 31 jwin_center_dialog(sound_dlg);
8567 31 jwin_center_dialog(triforce_dlg);
8568
8569 // digi_dp[1] += scrx;
8570 // digi_dp[2] += scry;
8571 // midi_dp[1] += scrx;
8572 // midi_dp[2] += scry;
8573 // pan_dp[1] += scrx;
8574 // pan_dp[2] += scry;
8575 // emus_dp[1] += scrx;
8576 // emus_dp[2] += scry;
8577 // buf_dp[1] += scrx;
8578 // buf_dp[2] += scry;
8579 // sfx_dp[1] += scrx;
8580 // sfx_dp[2] += scry;
8581 31 }
8582
8583 /*****************************/
8584 /**** Custom Sound System ****/
8585 /*****************************/
8586
8587 2611 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8588 {
8589
3/4
✓ Branch 0 taken 2353 times.
✓ Branch 1 taken 258 times.
✓ Branch 2 taken 2611 times.
✗ Branch 3 not taken.
2611 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8590 }
8591
8592 // Run an NSF, or a MIDI if the NSF is missing somehow.
8593 93 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8594 {
8595 93 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8596
8597 // Found it
8598
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 35 times.
93 if(newzcmusic!=NULL)
8599 {
8600 58 zcmusic_stop(zcmusic);
8601 58 zcmusic_unload_file(zcmusic);
8602 58 zc_stop_midi();
8603
8604 58 zcmusic=newzcmusic;
8605 58 zcmusic_play(zcmusic, emusic_volume);
8606
8607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(track>0)
8608 58 zcmusic_change_track(zcmusic,track);
8609
8610 58 return true;
8611 }
8612
8613 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8614
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 else if(midi>-1000)
8615 jukebox(midi);
8616
8617 35 return false;
8618 93 }
8619
8620 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8621 {
8622 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8623 // Found it
8624 if(newzcmusic!=NULL)
8625 {
8626 zcmusic_stop(zcmusic);
8627 zcmusic_unload_file(zcmusic);
8628 zc_stop_midi();
8629
8630 zcmusic=newzcmusic;
8631 zcmusic_play(zcmusic, emusic_volume);
8632
8633 if(track>0)
8634 zcmusic_change_track(zcmusic,track);
8635
8636 return true;
8637 }
8638
8639 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8640 else if(midi>-1000)
8641 jukebox(midi);
8642
8643 return false;
8644 }
8645
8646 int32_t get_zcmusicpos()
8647 {
8648 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8649 return debugtracething;
8650 return 0;
8651 }
8652
8653 void set_zcmusicpos(int32_t position)
8654 {
8655 zcmusic_set_curpos(zcmusic, position);
8656 }
8657
8658 void set_zcmusicspeed(int32_t speed)
8659 {
8660 int32_t newspeed = vbound(speed, 0, 10000);
8661 zcmusic_set_speed(zcmusic, newspeed);
8662 }
8663
8664 1290 void jukebox(int32_t index,int32_t loop)
8665 {
8666 1290 music_stop();
8667
8668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1290 times.
1290 if(index<0) index=MAXMIDIS-1;
8669
8670
1/2
✓ Branch 0 taken 1290 times.
✗ Branch 1 not taken.
1290 if(index>=MAXMIDIS) index=0;
8671
8672 1290 music_stop();
8673
8674 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8675 // stuck notes when a song stops. This fixes it.
8676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1290 times.
1290 if(strcmp(midi_driver->name, "DIGMID")==0)
8677 zc_set_volume(0, 0);
8678
8679 1290 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8680 1290 zc_play_midi((MIDI*)tunes[index].data,loop);
8681
8682
2/2
✓ Branch 0 taken 910 times.
✓ Branch 1 taken 380 times.
1290 if(tunes[index].start>0)
8683 380 zc_midi_seek(tunes[index].start);
8684
8685 1290 midi_loop_start = tunes[index].loop_start;
8686 1290 midi_loop_end = tunes[index].loop_end;
8687
8688 1290 currmidi=index;
8689 1290 master_volume(digi_volume,midi_volume);
8690 1290 midi_paused=false;
8691 1290 }
8692
8693 10509 void jukebox(int32_t index)
8694 {
8695
1/2
✓ Branch 0 taken 10509 times.
✗ Branch 1 not taken.
10509 if(index<0) index=MAXMIDIS-1;
8696
8697
1/2
✓ Branch 0 taken 10509 times.
✗ Branch 1 not taken.
10509 if(index>=MAXMIDIS) index=0;
8698
8699 // do nothing if it's already playing
8700
3/4
✓ Branch 0 taken 9219 times.
✓ Branch 1 taken 1290 times.
✓ Branch 2 taken 9219 times.
✗ Branch 3 not taken.
10509 if(index==currmidi && midi_pos>=0)
8701 {
8702 9219 midi_paused=false;
8703 9219 return;
8704 }
8705
8706 1290 jukebox(index,tunes[index].loop);
8707 10509 }
8708
8709 11749 void play_DmapMusic()
8710 {
8711 static char tfile[2048];
8712 static int32_t ttrack=0;
8713 11749 bool domidi=false;
8714
8715
2/2
✓ Branch 0 taken 1330 times.
✓ Branch 1 taken 10419 times.
11749 if(DMaps[currdmap].tmusic[0]!=0)
8716 {
8717
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 945 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
1715 if(zcmusic==NULL ||
8718
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8719
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8720 {
8721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 945 times.
945 if(zcmusic != NULL)
8722 {
8723 zcmusic_stop(zcmusic);
8724 zcmusic_unload_file(zcmusic);
8725 zcmusic = NULL;
8726 }
8727
8728 945 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8729
8730
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 859 times.
945 if(zcmusic!=NULL)
8731 {
8732 86 zc_stop_midi();
8733 86 strcpy(tfile,DMaps[currdmap].tmusic);
8734 86 zcmusic_play(zcmusic, emusic_volume);
8735 86 int32_t temptracks=0;
8736 86 temptracks=zcmusic_get_tracks(zcmusic);
8737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 temptracks=(temptracks<2)?1:temptracks;
8738 86 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
8739 86 zcmusic_change_track(zcmusic,ttrack);
8740 86 }
8741 else
8742 {
8743 859 tfile[0] = 0;
8744 859 domidi=true;
8745 }
8746 945 }
8747 1330 }
8748 else
8749 {
8750 10419 domidi=true;
8751 }
8752
8753
2/2
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 11278 times.
11749 if(domidi)
8754 {
8755 11278 int32_t m=DMaps[currdmap].midi;
8756
8757
3/4
✓ Branch 0 taken 11144 times.
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
11278 switch(m)
8758 {
8759 case 1:
8760 105 jukebox(ZC_MIDI_OVERWORLD);
8761 105 break;
8762
8763 case 2:
8764 29 jukebox(ZC_MIDI_DUNGEON);
8765 29 break;
8766
8767 case 3:
8768 jukebox(ZC_MIDI_LEVEL9);
8769 break;
8770
8771 default:
8772
3/4
✓ Branch 0 taken 10226 times.
✓ Branch 1 taken 918 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10226 times.
11144 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8773 10226 jukebox(m+MIDIOFFSET_DMAP);
8774 else
8775 918 music_stop();
8776 11144 }
8777 11278 }
8778 11749 }
8779
8780 11786 void playLevelMusic()
8781 {
8782 11786 int32_t m=tmpscr->screen_midi;
8783
8784
3/6
✓ Branch 0 taken 11733 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
11786 switch(m)
8785 {
8786 case -2:
8787 12 music_stop();
8788 12 break;
8789
8790 case -1:
8791 11733 play_DmapMusic();
8792 11733 break;
8793
8794 case 1:
8795 jukebox(ZC_MIDI_OVERWORLD);
8796 break;
8797
8798 case 2:
8799 jukebox(ZC_MIDI_DUNGEON);
8800 break;
8801
8802 case 3:
8803 jukebox(ZC_MIDI_LEVEL9);
8804 break;
8805
8806 default:
8807
2/4
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
41 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8808 41 jukebox(m+MIDIOFFSET_MAPSCR);
8809 else
8810 music_stop();
8811 41 }
8812 11786 }
8813
8814 1321 void master_volume(int32_t dv,int32_t mv)
8815 {
8816
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1321 times.
✓ Branch 2 taken 1321 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1321 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1321 times.
✗ Branch 7 not taken.
1321 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8817
8818
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1321 times.
✓ Branch 2 taken 1321 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1321 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1321 times.
✗ Branch 7 not taken.
1321 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8819
8820
6/6
✓ Branch 0 taken 1286 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 1319 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1284 times.
✓ Branch 5 taken 35 times.
1321 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8821 1321 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
8822 1321 }
8823
8824 /*****************/
8825 /***** SFX *****/
8826 /*****************/
8827
8828 // array of voices, one for each sfx sample in the data file
8829 // 0+ = voice #
8830 // -1 = voice not allocated
8831 31 void Z_init_sound()
8832 {
8833
2/2
✓ Branch 0 taken 7936 times.
✓ Branch 1 taken 31 times.
7967 for(int32_t i=0; i<WAV_COUNT; i++)
8834 7936 sfx_voice[i]=-1;
8835
8836
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 31 times.
248 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8837 217 tunes[i].data = (MIDI*)mididata[i].dat;
8838
8839
2/2
✓ Branch 0 taken 7812 times.
✓ Branch 1 taken 31 times.
7843 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8840 7812 tunes[ZC_MIDI_COUNT+j].data=NULL;
8841
8842 31 master_volume(digi_volume,midi_volume);
8843 31 }
8844
8845 // returns number of voices currently allocated
8846 int32_t sfx_count()
8847 {
8848 int32_t c=0;
8849
8850 for(int32_t i=0; i<WAV_COUNT; i++)
8851 if(sfx_voice[i]!=-1)
8852 ++c;
8853
8854 return c;
8855 }
8856
8857 // clean up finished samples
8858 7481008 void sfx_cleanup()
8859 {
8860
2/2
✓ Branch 0 taken 1915138048 times.
✓ Branch 1 taken 7481008 times.
1922619056 for(int32_t i=0; i<WAV_COUNT; i++)
8861
3/4
✓ Branch 0 taken 614039 times.
✓ Branch 1 taken 1914524009 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 614039 times.
1915752087 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8862 {
8863 614039 deallocate_voice(sfx_voice[i]);
8864 614039 sfx_voice[i]=-1;
8865 614039 }
8866 7481008 }
8867
8868 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8869 // if a voice is already allocated (and/or playing), then it just returns true
8870 // Returns true: voice is allocated
8871 // false: unsuccessful
8872 944287 bool sfx_init(int32_t index)
8873 {
8874 // check index
8875
3/4
✓ Branch 0 taken 681606 times.
✓ Branch 1 taken 262681 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 681606 times.
944287 if(index<=0 || index>=WAV_COUNT)
8876 262681 return false;
8877
8878
2/2
✓ Branch 0 taken 67541 times.
✓ Branch 1 taken 614065 times.
681606 if(sfx_voice[index]==-1)
8879 {
8880
2/2
✓ Branch 0 taken 163578 times.
✓ Branch 1 taken 450487 times.
614065 if(sfxdat)
8881 {
8882
1/2
✓ Branch 0 taken 163578 times.
✗ Branch 1 not taken.
163578 if(index<Z35)
8883 {
8884 163578 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8885 163578 }
8886 else
8887 {
8888 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8889 }
8890 163578 }
8891 else
8892 {
8893 450487 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8894 }
8895
8896 614065 voice_set_volume(sfx_voice[index], sfx_volume);
8897 614065 }
8898
8899 681606 return sfx_voice[index] != -1;
8900 944287 }
8901
8902 // plays an sfx sample
8903 801188 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
8904 {
8905
2/2
✓ Branch 0 taken 608323 times.
✓ Branch 1 taken 192865 times.
801188 if(!sfx_init(index))
8906 192865 return;
8907
8908 608323 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8909 608323 voice_set_pan(sfx_voice[index],pan);
8910
8911 608323 int32_t pos = voice_get_position(sfx_voice[index]);
8912
8913
2/2
✓ Branch 0 taken 288965 times.
✓ Branch 1 taken 319358 times.
608323 if(restart) voice_set_position(sfx_voice[index],0);
8914
8915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 608323 times.
608323 if(pos<=0)
8916 608323 voice_start(sfx_voice[index]);
8917
8918
3/4
✓ Branch 0 taken 319358 times.
✓ Branch 1 taken 288965 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 319358 times.
608323 if (restart && replay_is_debug())
8919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 319358 times.
319358 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8920 801188 }
8921
8922 // true if sfx is allocated
8923 34070 bool sfx_allocated(int32_t index)
8924 {
8925
3/4
✓ Branch 0 taken 9405 times.
✓ Branch 1 taken 24665 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9405 times.
34070 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8926 }
8927
8928 // start it (in loop mode) if it's not already playing,
8929 // otherwise adjust it to play in loop mode -DD
8930 143099 void cont_sfx(int32_t index)
8931 {
8932
2/2
✓ Branch 0 taken 69816 times.
✓ Branch 1 taken 73283 times.
143099 if(!sfx_init(index))
8933 {
8934 69816 return;
8935 }
8936
8937
1/2
✓ Branch 0 taken 73283 times.
✗ Branch 1 not taken.
73283 if(voice_get_position(sfx_voice[index])<=0)
8938 {
8939 73283 voice_set_position(sfx_voice[index],0);
8940 73283 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8941 73283 voice_start(sfx_voice[index]);
8942 73283 }
8943 else
8944 {
8945 adjust_sfx(index, 128, true);
8946 }
8947 143099 }
8948
8949 // adjust parameters while playing
8950 3829 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8951 {
8952
5/6
✓ Branch 0 taken 2170 times.
✓ Branch 1 taken 1659 times.
✓ Branch 2 taken 2170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 2156 times.
3829 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8953 3815 return;
8954
8955 14 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8956 14 voice_set_pan(sfx_voice[index],pan);
8957 3829 }
8958
8959 // pauses a voice
8960 1593 void pause_sfx(int32_t index)
8961 {
8962
3/6
✓ Branch 0 taken 1593 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1593 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1593 times.
1593 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8963 voice_stop(sfx_voice[index]);
8964 1593 }
8965
8966 // resumes a voice
8967 688 void resume_sfx(int32_t index)
8968 {
8969
3/6
✓ Branch 0 taken 688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 688 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 688 times.
688 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8970 voice_start(sfx_voice[index]);
8971 688 }
8972
8973 // pauses all active voices
8974 296 void pause_all_sfx()
8975 {
8976
2/2
✓ Branch 0 taken 75776 times.
✓ Branch 1 taken 296 times.
76072 for(int32_t i=0; i<WAV_COUNT; i++)
8977
2/2
✓ Branch 0 taken 75774 times.
✓ Branch 1 taken 2 times.
75778 if(sfx_voice[i]!=-1)
8978 2 voice_stop(sfx_voice[i]);
8979 296 }
8980
8981 // resumes all paused voices
8982 282 void resume_all_sfx()
8983 {
8984
2/2
✓ Branch 0 taken 72192 times.
✓ Branch 1 taken 282 times.
72474 for(int32_t i=0; i<WAV_COUNT; i++)
8985
1/2
✓ Branch 0 taken 72192 times.
✗ Branch 1 not taken.
72192 if(sfx_voice[i]!=-1)
8986 voice_start(sfx_voice[i]);
8987 282 }
8988
8989 // stops an sfx and deallocates the voice
8990 6023527 void stop_sfx(int32_t index)
8991 {
8992
3/4
✓ Branch 0 taken 5267427 times.
✓ Branch 1 taken 756100 times.
✓ Branch 2 taken 5267427 times.
✗ Branch 3 not taken.
6023527 if(index<=0 || index>=WAV_COUNT)
8993 756100 return;
8994
8995
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 5267414 times.
5267427 if(sfx_voice[index]!=-1)
8996 {
8997 13 deallocate_voice(sfx_voice[index]);
8998 13 sfx_voice[index]=-1;
8999 13 }
9000 6023527 }
9001
9002 // Stops SFX played by Hero's item of the given family
9003 131275 void stop_item_sfx(int32_t family)
9004 {
9005 131275 int32_t id=current_item_id(family);
9006
9007
2/2
✓ Branch 0 taken 130875 times.
✓ Branch 1 taken 400 times.
131275 if(id<0)
9008 130875 return;
9009
9010 400 stop_sfx(itemsbuf[id].usesound);
9011 131275 }
9012
9013 2106 void kill_sfx()
9014 {
9015
2/2
✓ Branch 0 taken 539136 times.
✓ Branch 1 taken 2106 times.
541242 for(int32_t i=0; i<WAV_COUNT; i++)
9016
2/2
✓ Branch 0 taken 539123 times.
✓ Branch 1 taken 13 times.
539149 if(sfx_voice[i]!=-1)
9017 {
9018 13 deallocate_voice(sfx_voice[i]);
9019 13 sfx_voice[i]=-1;
9020 13 }
9021 2106 }
9022
9023 561327 int32_t pan(int32_t x)
9024 {
9025
1/4
✓ Branch 0 taken 561327 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
561327 switch(pan_style)
9026 {
9027 case 0:
9028 return 128;
9029
9030 case 1:
9031 561327 return vbound((x>>1)+68,0,255);
9032
9033 case 2:
9034 return vbound(((x*3)>>2)+36,0,255);
9035 }
9036
9037 return vbound(x,0,255);
9038 561327 }
9039
9040 /*******************************/
9041 /******* Input Handlers ********/
9042 /*******************************/
9043
9044 19693871 bool joybtn(int32_t b)
9045 {
9046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19693871 times.
19693871 if(b == 0)
9047 return false;
9048
9049 19693871 return joy[joystick_index].button[b-1].b !=0;
9050 19693871 }
9051
9052 const char* joybtn_name(int32_t b)
9053 {
9054 if(b == 0)
9055 return "";
9056
9057 return joy[joystick_index].button[b-1].name;
9058 }
9059
9060 int32_t next_press_key();
9061
9062 int32_t next_press_btn()
9063 {
9064 clear_keybuf();
9065 /*bool b[joy[joystick_index].num_buttons+1];
9066
9067 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9068 b[i]=joybtn(i);*/
9069
9070 //first, we need to wait until they're pressing no buttons
9071 for(;;)
9072 {
9073 if(keypressed())
9074 {
9075 switch(readkey()>>8)
9076 {
9077 case KEY_ESC:
9078 return -1;
9079
9080 case KEY_SPACE:
9081 return 0;
9082 }
9083 }
9084
9085 poll_joystick();
9086 bool done = true;
9087
9088 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9089 {
9090 if(joybtn(i)) done = false;
9091 }
9092
9093 if(done) break;
9094 rest(1);
9095 }
9096
9097 //now, we need to wait for them to press any button
9098 for(;;)
9099 {
9100 if(keypressed())
9101 {
9102 switch(readkey()>>8)
9103 {
9104 case KEY_ESC:
9105 return -1;
9106
9107 case KEY_SPACE:
9108 return 0;
9109 }
9110 }
9111
9112 poll_joystick();
9113
9114 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9115 {
9116 if(joybtn(i)) return i;
9117 }
9118 rest(1);
9119 }
9120 }
9121
9122 155827264 static bool rButton(bool &btn, bool &flag, bool* rawbtn = nullptr)
9123 {
9124
2/2
✓ Branch 0 taken 150362686 times.
✓ Branch 1 taken 5464578 times.
155827264 bool ret = btn && !flag;
9125
2/2
✓ Branch 0 taken 132992741 times.
✓ Branch 1 taken 22834523 times.
155827264 flag = rawbtn ? *rawbtn : btn;
9126
9127 155827264 return ret;
9128 }
9129 1431671 static bool rButtonPeek(bool btn, bool flag)
9130 {
9131
2/2
✓ Branch 0 taken 1339943 times.
✓ Branch 1 taken 91728 times.
1431671 if(!btn)
9132 {
9133 1339943 return false;
9134 }
9135
2/2
✓ Branch 0 taken 15558 times.
✓ Branch 1 taken 76170 times.
91728 else if(!flag)
9136 {
9137 15558 return true;
9138 }
9139
9140 76170 return false;
9141 1431671 }
9142
9143 // Updated only by keyboard/gamepad.
9144 // If in replay mode, this is set directly by the replay system.
9145 // This should never be read from directly - use control_state instead.
9146 bool raw_control_state[ZC_CONTROL_STATES];
9147
9148 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9149 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9150 // lasts until the next call to load_control_state.
9151 bool control_state[ZC_CONTROL_STATES];
9152 bool disable_control[ZC_CONTROL_STATES];
9153 bool drunk_toggle_state[11];
9154 bool disabledKeys[127];
9155 bool KeyInput[127];
9156 bool KeyPress[127];
9157
9158 bool key_current_frame[127];
9159 bool key_previous_frame[127];
9160
9161 static bool key_system[127];
9162 static bool key_system_previous[127];
9163 static bool key_system_press[127];
9164
9165 bool button_press[ZC_CONTROL_STATES];
9166 bool button_hold[ZC_CONTROL_STATES];
9167
9168 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9169 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9170 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9171 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9172 #define STICK_PRECISION 56 //define your own sensitivity
9173
9174 6294842 void load_control_state()
9175 {
9176 6294842 load_control_called_this_frame = true;
9177
9178
4/4
✓ Branch 0 taken 3423641 times.
✓ Branch 1 taken 2871201 times.
✓ Branch 2 taken 856645 times.
✓ Branch 3 taken 2566996 times.
6294842 if (replay_get_version() >= 8 && replay_get_version() < 11)
9179 {
9180
2/2
✓ Branch 0 taken 46205928 times.
✓ Branch 1 taken 2566996 times.
48772924 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9181 46205928 down_control_states[i] = raw_control_state[i];
9182 2566996 }
9183
9184
1/2
✓ Branch 0 taken 6294842 times.
✗ Branch 1 not taken.
6294842 if (!replay_is_replaying())
9185 {
9186 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9187 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9188 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9189 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9190 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9191 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9192 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9193 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9194 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9195 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9196 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9197 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9198 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9199 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9200
9201 if(num_joysticks != 0)
9202 {
9203 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9204 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9205 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9206 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9207 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9208 }
9209 else
9210 {
9211 raw_control_state[14] = false;
9212 raw_control_state[15] = false;
9213 raw_control_state[16] = false;
9214 raw_control_state[17] = false;
9215 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9216 }
9217 bool did_bad_cutscene_btn = false;
9218 for(int q = 0; q < 18; ++q)
9219 if(raw_control_state[q] && !active_cutscene.can_button(q))
9220 {
9221 raw_control_state[q] = false;
9222 did_bad_cutscene_btn = true;
9223 }
9224 if(did_bad_cutscene_btn)
9225 active_cutscene.error();
9226 }
9227
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 6294839 times.
6294842 if (replay_is_active())
9228 {
9229
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 5279624 times.
6294839 if (replay_get_version() < 3)
9230 1015215 replay_poll();
9231
3/4
✓ Branch 0 taken 5279624 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3518249 times.
✓ Branch 3 taken 1761375 times.
5279624 else if (replay_is_replaying() && replay_get_version() < 6)
9232 1761375 replay_peek_input();
9233
5/6
✓ Branch 0 taken 3518249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3423641 times.
✓ Branch 3 taken 94608 times.
✓ Branch 4 taken 856645 times.
✓ Branch 5 taken 2566996 times.
3518249 else if (replay_is_replaying() && replay_get_version() >= 8 && replay_get_version() < 11)
9234 2566996 replay_peek_input();
9235
2/2
✓ Branch 0 taken 5177373 times.
✓ Branch 1 taken 1117466 times.
6294839 if (replay_get_version() == 8)
9236 1117466 update_keys();
9237 6294839 }
9238
9239 // Some test replay files were made before a serious input bug was fixed, so instead
9240 // of re-doing them or tossing them out, just check for that zplay version.
9241
3/4
✓ Branch 0 taken 6294836 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 6172936 times.
6294842 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
9242
2/2
✓ Branch 0 taken 113307048 times.
✓ Branch 1 taken 6294836 times.
119601884 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9243 {
9244 113307048 control_state[i] = raw_control_state[i];
9245
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 63819738 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
113307048 if (botched_input && !control_state[i])
9246 47077142 down_control_states[i] = false;
9247 113307048 }
9248
9249 6294836 button_press[0]=rButton(control_state[0],button_hold[0]);
9250 6294836 button_press[1]=rButton(control_state[1],button_hold[1]);
9251 6294836 button_press[2]=rButton(control_state[2],button_hold[2]);
9252 6294836 button_press[3]=rButton(control_state[3],button_hold[3]);
9253 6294836 button_press[4]=rButton(control_state[4],button_hold[4]);
9254 6294836 button_press[5]=rButton(control_state[5],button_hold[5]);
9255 6294836 button_press[6]=rButton(control_state[6],button_hold[6]);
9256 6294836 button_press[7]=rButton(control_state[7],button_hold[7]);
9257 6294836 button_press[8]=rButton(control_state[8],button_hold[8]);
9258 6294836 button_press[9]=rButton(control_state[9],button_hold[9]);
9259 6294836 button_press[10]=rButton(control_state[10],button_hold[10]);
9260 6294836 button_press[11]=rButton(control_state[11],button_hold[11]);
9261 6294836 button_press[12]=rButton(control_state[12],button_hold[12]);
9262 6294836 button_press[13]=rButton(control_state[13],button_hold[13]);
9263 6294836 button_press[14]=rButton(control_state[14],button_hold[14]);
9264 6294836 button_press[15]=rButton(control_state[15],button_hold[15]);
9265 6294836 button_press[16]=rButton(control_state[16],button_hold[16]);
9266 6294836 button_press[17]=rButton(control_state[17],button_hold[17]);
9267 6294836 }
9268
9269 // Returns true if any game key is pressed. This is needed because keypressed()
9270 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9271 32575662 bool zc_key_pressed()
9272 //may also need to use zc_getrawkey
9273 {
9274
7/10
✓ Branch 0 taken 26367901 times.
✓ Branch 1 taken 6207761 times.
✓ Branch 2 taken 6207761 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6207761 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5218286 times.
✓ Branch 7 taken 5218286 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1928083 times.
34503745 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9275
4/6
✓ Branch 0 taken 5218286 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5218286 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3932854 times.
✓ Branch 5 taken 3932854 times.
5218286 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9276
4/6
✓ Branch 0 taken 3932854 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3932854 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2522346 times.
✓ Branch 5 taken 2522346 times.
3932854 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9277
4/6
✓ Branch 0 taken 2522346 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2522346 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2167516 times.
✓ Branch 5 taken 2167516 times.
2522346 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9278
1/2
✓ Branch 0 taken 2167516 times.
✗ Branch 1 not taken.
2167516 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9279
3/4
✓ Branch 0 taken 2054751 times.
✓ Branch 1 taken 112765 times.
✓ Branch 2 taken 2054751 times.
✗ Branch 3 not taken.
2167516 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9280
3/4
✓ Branch 0 taken 1956329 times.
✓ Branch 1 taken 98422 times.
✓ Branch 2 taken 1956329 times.
✗ Branch 3 not taken.
2054751 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9281
3/4
✓ Branch 0 taken 1942626 times.
✓ Branch 1 taken 13703 times.
✓ Branch 2 taken 1942626 times.
✗ Branch 3 not taken.
1956329 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9282
3/4
✓ Branch 0 taken 1930532 times.
✓ Branch 1 taken 12094 times.
✓ Branch 2 taken 1930532 times.
✗ Branch 3 not taken.
1942626 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9283
3/4
✓ Branch 0 taken 1928941 times.
✓ Branch 1 taken 1591 times.
✓ Branch 2 taken 1928941 times.
✗ Branch 3 not taken.
1930532 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9284
3/4
✓ Branch 0 taken 1928889 times.
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 1928889 times.
✗ Branch 3 not taken.
1928941 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9285
3/4
✓ Branch 0 taken 1928102 times.
✓ Branch 1 taken 787 times.
✓ Branch 2 taken 1928102 times.
✗ Branch 3 not taken.
1928889 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9286
2/4
✓ Branch 0 taken 1928102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1928102 times.
✗ Branch 3 not taken.
1928102 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9287
2/2
✓ Branch 0 taken 1928083 times.
✓ Branch 1 taken 19 times.
1928102 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9288 58329583 return true;
9289
9290 1928083 return false;
9291 7521864 }
9292
9293 124696648 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9294 {
9295 124696648 bool ret = false, drunkstate = false, rawret = false;
9296 124696648 bool* flag = &down_control_states[btn];
9297
2/7
✓ Branch 0 taken 117166891 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 7529757 times.
124696648 switch(btn)
9298 {
9299 case btnF12:
9300 ret = zc_getkey(KEY_F12, ignoreDisable);
9301 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
9302 eatEntirely = false;
9303 break;
9304 case btnF11:
9305 ret = zc_getkey(KEY_F11, ignoreDisable);
9306 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
9307 eatEntirely = false;
9308 break;
9309 case btnF5:
9310 ret = zc_getkey(KEY_F5, ignoreDisable);
9311 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
9312 eatEntirely = false;
9313 break;
9314 case btnQ:
9315 ret = zc_getkey(KEY_Q, ignoreDisable);
9316 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
9317 eatEntirely = false;
9318 break;
9319 case btnI:
9320 ret = zc_getkey(KEY_I, ignoreDisable);
9321 rawret = zc_getrawkey(KEY_I, ignoreDisable);
9322 eatEntirely = false;
9323 break;
9324 case btnM:
9325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7529757 times.
7529757 if(FFCore.kb_typing_mode) return false;
9326 7529757 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9327 7529757 eatEntirely = false;
9328 7529757 break;
9329 default: //control_state[] index
9330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117166891 times.
117166891 if(FFCore.kb_typing_mode) return false;
9331
5/6
✓ Branch 0 taken 116902695 times.
✓ Branch 1 taken 264196 times.
✓ Branch 2 taken 2257162 times.
✓ Branch 3 taken 114645533 times.
✓ Branch 4 taken 2257162 times.
✗ Branch 5 not taken.
117166891 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9332
2/2
✓ Branch 0 taken 6338332 times.
✓ Branch 1 taken 110828559 times.
117166891 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9333
4/4
✓ Branch 0 taken 105659561 times.
✓ Branch 1 taken 11507330 times.
✓ Branch 2 taken 1490 times.
✓ Branch 3 taken 11505840 times.
128674221 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9334 117166891 rawret = raw_control_state[btn];
9335 117166891 }
9336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124696648 times.
124696648 assert(flag);
9337
2/2
✓ Branch 0 taken 80744761 times.
✓ Branch 1 taken 43951887 times.
124696648 if(press)
9338 {
9339
2/2
✓ Branch 0 taken 1431671 times.
✓ Branch 1 taken 42520216 times.
43951887 if(peek)
9340 1431671 ret = rButtonPeek(ret, *flag);
9341
3/4
✓ Branch 0 taken 42520216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22834523 times.
✓ Branch 3 taken 19685693 times.
42520216 else if (replay_is_active() && replay_get_version() < 8) ret = rButton(ret, *flag);
9342 22834523 else ret = rButton(ret, *flag, &rawret);
9343 43951887 }
9344
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 124696648 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
124696648 if(eatEntirely && ret) control_state[btn] = false;
9345
3/4
✓ Branch 0 taken 94394730 times.
✓ Branch 1 taken 30301918 times.
✓ Branch 2 taken 94394730 times.
✗ Branch 3 not taken.
124696648 if(drunk && drunkstate) ret = !ret;
9346 124696648 return ret;
9347 124696648 }
9348
9349 6162921 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9350 {
9351 6162921 byte ret = 0;
9352
2/2
✓ Branch 0 taken 4729181 times.
✓ Branch 1 taken 1433740 times.
6162921 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9353
2/2
✓ Branch 0 taken 6162359 times.
✓ Branch 1 taken 562 times.
6162921 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9354
2/2
✓ Branch 0 taken 6162484 times.
✓ Branch 1 taken 437 times.
6162921 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9355
2/2
✓ Branch 0 taken 6162484 times.
✓ Branch 1 taken 437 times.
6162921 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9356
2/2
✓ Branch 0 taken 6162484 times.
✓ Branch 1 taken 437 times.
6162921 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9357
2/2
✓ Branch 0 taken 6162484 times.
✓ Branch 1 taken 437 times.
6162921 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9358
2/2
✓ Branch 0 taken 6162484 times.
✓ Branch 1 taken 437 times.
6162921 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9359
2/2
✓ Branch 0 taken 6162484 times.
✓ Branch 1 taken 437 times.
6162921 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9360 6162921 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9361 }
9362
9363 1114 byte checkIntBtnVal(byte intbtn, byte vals)
9364 {
9365 1114 return intbtn&vals;
9366 }
9367
9368 1455707 bool Up()
9369 {
9370 1455707 return getInput(btnUp);
9371 }
9372 89081 bool Down()
9373 {
9374 89081 return getInput(btnDown);
9375 }
9376 179248 bool Left()
9377 {
9378 179248 return getInput(btnLeft);
9379 }
9380 200431 bool Right()
9381 {
9382 200431 return getInput(btnRight);
9383 }
9384 99306 bool cAbtn()
9385 {
9386 99306 return getInput(btnA);
9387 }
9388 1318258 bool cBbtn()
9389 {
9390 1318258 return getInput(btnB);
9391 }
9392 bool cSbtn()
9393 {
9394 return getInput(btnS);
9395 }
9396 40856 bool cLbtn()
9397 {
9398 40856 return getInput(btnL);
9399 }
9400 40856 bool cRbtn()
9401 {
9402 40856 return getInput(btnR);
9403 }
9404 bool cPbtn()
9405 {
9406 return getInput(btnP);
9407 }
9408 bool cEx1btn()
9409 {
9410 return getInput(btnEx1);
9411 }
9412 bool cEx2btn()
9413 {
9414 return getInput(btnEx2);
9415 }
9416 bool cEx3btn()
9417 {
9418 return getInput(btnEx3);
9419 }
9420 bool cEx4btn()
9421 {
9422 return getInput(btnEx4);
9423 }
9424 bool AxisUp()
9425 {
9426 return getInput(btnAxisUp);
9427 }
9428 bool AxisDown()
9429 {
9430 return getInput(btnAxisDown);
9431 }
9432 bool AxisLeft()
9433 {
9434 return getInput(btnAxisLeft);
9435 }
9436 bool AxisRight()
9437 {
9438 return getInput(btnAxisRight);
9439 }
9440
9441 bool cMbtn()
9442 {
9443 return getInput(btnM);
9444 }
9445 bool cF12()
9446 {
9447 return getInput(btnF12);
9448 }
9449 bool cF11()
9450 {
9451 return getInput(btnF11);
9452 }
9453 bool cF5()
9454 {
9455 return getInput(btnF5);
9456 }
9457 bool cQ()
9458 {
9459 return getInput(btnQ);
9460 }
9461 bool cI()
9462 {
9463 return getInput(btnI);
9464 }
9465
9466 120114 bool rUp()
9467 {
9468 120114 return getInput(btnUp, true);
9469 }
9470 120025 bool rDown()
9471 {
9472 120025 return getInput(btnDown, true);
9473 }
9474 119973 bool rLeft()
9475 {
9476 119973 return getInput(btnLeft, true);
9477 }
9478 119511 bool rRight()
9479 {
9480 119511 return getInput(btnRight, true);
9481 }
9482 2646 bool rAbtn()
9483 {
9484 2646 return getInput(btnA, true);
9485 }
9486 120893 bool rBbtn()
9487 {
9488 120893 return getInput(btnB, true);
9489 }
9490 6103092 bool rSbtn()
9491 {
9492 6103092 return getInput(btnS, true);
9493 }
9494 7521864 bool rMbtn()
9495 {
9496 7521864 return getInput(btnM, true);
9497 }
9498 119304 bool rLbtn()
9499 {
9500 119304 return getInput(btnL, true);
9501 }
9502 119299 bool rRbtn()
9503 {
9504 119299 return getInput(btnR, true);
9505 }
9506 6022484 bool rPbtn()
9507 {
9508 6022484 return getInput(btnP, true);
9509 }
9510 bool rEx1btn()
9511 {
9512 return getInput(btnEx1, true);
9513 }
9514 bool rEx2btn()
9515 {
9516 return getInput(btnEx2, true);
9517 }
9518 130178 bool rEx3btn()
9519 {
9520 130178 return getInput(btnEx3, true);
9521 }
9522 130178 bool rEx4btn()
9523 {
9524 130178 return getInput(btnEx4, true);
9525 }
9526 bool rAxisUp()
9527 {
9528 return getInput(btnAxisUp, true);
9529 }
9530 bool rAxisDown()
9531 {
9532 return getInput(btnAxisDown, true);
9533 }
9534 bool rAxisLeft()
9535 {
9536 return getInput(btnAxisLeft, true);
9537 }
9538 bool rAxisRight()
9539 {
9540 return getInput(btnAxisRight, true);
9541 }
9542
9543 bool rF11()
9544 {
9545 return getInput(btnF11, true);
9546 }
9547 bool rQ()
9548 {
9549 return getInput(btnQ, true);
9550 }
9551 bool rI()
9552 {
9553 return getInput(btnI, true);
9554 }
9555
9556 15284385 bool DrunkUp()
9557 {
9558 15284385 return getInput(btnUp, false, true);
9559 }
9560 14241704 bool DrunkDown()
9561 {
9562 14241704 return getInput(btnDown, false, true);
9563 }
9564 8970450 bool DrunkLeft()
9565 {
9566 8970450 return getInput(btnLeft, false, true);
9567 }
9568 7781243 bool DrunkRight()
9569 {
9570 7781243 return getInput(btnRight, false, true);
9571 }
9572 6663872 bool DrunkcAbtn()
9573 {
9574 6663872 return getInput(btnA, false, true);
9575 }
9576 6560211 bool DrunkcBbtn()
9577 {
9578 6560211 return getInput(btnB, false, true);
9579 }
9580 5981304 bool DrunkcEx1btn()
9581 {
9582 5981304 return getInput(btnEx1, false, true);
9583 }
9584 5981324 bool DrunkcEx2btn()
9585 {
9586 5981324 return getInput(btnEx2, false, true);
9587 }
9588 bool DrunkcSbtn()
9589 {
9590 return getInput(btnS, false, true);
9591 }
9592 bool DrunkcMbtn()
9593 {
9594 return getInput(btnM, false, true);
9595 }
9596 bool DrunkcLbtn()
9597 {
9598 return getInput(btnL, false, true);
9599 }
9600 bool DrunkcRbtn()
9601 {
9602 return getInput(btnR, false, true);
9603 }
9604 bool DrunkcPbtn()
9605 {
9606 return getInput(btnP, false, true);
9607 }
9608
9609 bool DrunkrUp()
9610 {
9611 return getInput(btnUp, true, true);
9612 }
9613 bool DrunkrDown()
9614 {
9615 return getInput(btnDown, true, true);
9616 }
9617 bool DrunkrLeft()
9618 {
9619 return getInput(btnLeft, true, true);
9620 }
9621 bool DrunkrRight()
9622 {
9623 return getInput(btnRight, true, true);
9624 }
9625 5007308 bool DrunkrAbtn()
9626 {
9627 5007308 return getInput(btnA, true, true);
9628 }
9629 5021777 bool DrunkrBbtn()
9630 {
9631 5021777 return getInput(btnB, true, true);
9632 }
9633 71669 bool DrunkrEx1btn()
9634 {
9635 71669 return getInput(btnEx1, true, true);
9636 }
9637 71662 bool DrunkrEx2btn()
9638 {
9639 71662 return getInput(btnEx2, true, true);
9640 }
9641 bool DrunkrEx3btn()
9642 {
9643 return getInput(btnEx3, true, true);
9644 }
9645 bool DrunkrEx4btn()
9646 {
9647 return getInput(btnEx4, true, true);
9648 }
9649 bool DrunkrSbtn()
9650 {
9651 return getInput(btnS, true, true);
9652 }
9653 bool DrunkrMbtn()
9654 {
9655 return getInput(btnM, true, true);
9656 }
9657 5662007 bool DrunkrLbtn()
9658 {
9659 5662007 return getInput(btnL, true, true);
9660 }
9661 5658890 bool DrunkrRbtn()
9662 {
9663 5658890 return getInput(btnR, true, true);
9664 }
9665 bool DrunkrPbtn()
9666 {
9667 return getInput(btnP, true, true);
9668 }
9669
9670 7893 void eat_buttons()
9671 {
9672 7893 getInput(btnA, true, false, true);
9673 7893 getInput(btnB, true, false, true);
9674 7893 getInput(btnS, true, false, true);
9675 7893 getInput(btnM, true, false, true);
9676 7893 getInput(btnL, true, false, true);
9677 7893 getInput(btnR, true, false, true);
9678 7893 getInput(btnP, true, false, true);
9679 7893 getInput(btnEx1, true, false, true);
9680 7893 getInput(btnEx2, true, false, true);
9681 7893 getInput(btnEx3, true, false, true);
9682 7893 getInput(btnEx4, true, false, true);
9683 7893 }
9684
9685 // Is true for the _first frame_ of a key press.
9686 // But! it is possible that a script manually sets the value of KeyPress,
9687 // in which case it will be restored to the "true" value based on `key_current_frame`
9688 // and `key_previous_frame` on the next frame.
9689 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9690 {
9691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9693 {
9694 case KEY_F7:
9695 case KEY_F8:
9696 case KEY_F9:
9697 return KeyPress[k];
9698
9699 default:
9700
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1 times.
14 return KeyPress[k] && !disabledKeys[k];
9701 }
9702 14 }
9703
9704 // Is true for _every frame_ a key is held down.
9705 // But! it is possible that a script manually sets the value of KeyInput,
9706 // in which case it will be restored to the "true" value based on `key_current_frame`
9707 // on the next frame.
9708 bool zc_getkey(int32_t k, bool ignoreDisable)
9709 {
9710 if(ignoreDisable) return KeyInput[k];
9711 switch(k)
9712 {
9713 case KEY_F7:
9714 case KEY_F8:
9715 case KEY_F9:
9716 return KeyInput[k];
9717
9718 default:
9719 return KeyInput[k] && !disabledKeys[k];
9720 }
9721 }
9722
9723 // Reads (and then clears) the current frame key state directly.
9724 // Scripts can also modify `key_current_frame`.
9725 143 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9726 {
9727
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 141 times.
143 if(zc_getrawkey(k, ignoreDisable))
9728 {
9729 2 _key[k]=key[k]=key_current_frame[k]=0;
9730 2 return true;
9731 }
9732 141 _key[k]=key[k]=key_current_frame[k]=0;
9733 141 return false;
9734 143 }
9735
9736 // Reads the current frame key state directly.
9737 // Scripts can also modify `key_current_frame`.
9738 50698799 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9739 {
9740
2/2
✓ Branch 0 taken 43176907 times.
✓ Branch 1 taken 7521892 times.
50698799 if(ignoreDisable) return key_current_frame[k];
9741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7521892 times.
7521892 switch(k)
9742 {
9743 case KEY_F7:
9744 case KEY_F8:
9745 case KEY_F9:
9746 return key_current_frame[k];
9747
9748 default:
9749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7521892 times.
7521892 return key_current_frame[k] && !disabledKeys[k];
9750 }
9751 50698799 }
9752
9753 // Only used for a handful of keys, like tilde and Function keys.
9754 // This state is never read within the game.
9755 // It exists so that all keyboard input still functions during replay,
9756 // without inadvertently doing things like toggling throttling if the player
9757 // presses ~
9758 15043800 bool zc_get_system_key(int32_t k)
9759 {
9760 15043800 return key_system[k];
9761 }
9762
9763 // True for the _first_ frame of a key press.
9764 67696776 bool zc_read_system_key(int32_t k)
9765 {
9766 67696776 return key_system_press[k];
9767 }
9768
9769 955276728 bool is_system_key(int32_t k)
9770 {
9771
2/2
✓ Branch 0 taken 887579952 times.
✓ Branch 1 taken 67696776 times.
955276728 switch (k)
9772 {
9773 case KEY_BACKQUOTE:
9774 case KEY_CLOSEBRACE:
9775 case KEY_END:
9776 case KEY_HOME:
9777 case KEY_OPENBRACE:
9778 case KEY_PGDN:
9779 case KEY_PGUP:
9780 case KEY_TAB:
9781 case KEY_TILDE:
9782 67696776 return true;
9783 }
9784 887579952 return is_Fkey(k);
9785 955276728 }
9786
9787 7521864 void update_system_keys()
9788 {
9789
2/2
✓ Branch 0 taken 955276728 times.
✓ Branch 1 taken 7521864 times.
962798592 for (int32_t q = 0; q < 127; ++q)
9790 {
9791
2/2
✓ Branch 0 taken 157959144 times.
✓ Branch 1 taken 797317584 times.
955276728 if (!is_system_key(q))
9792 797317584 continue;
9793
9794 157959144 key_system[q] = key[q];
9795
1/2
✓ Branch 0 taken 157959144 times.
✗ Branch 1 not taken.
157959144 key_system_press[q] = key_system[q] && !key_system_previous[q];
9796 157959144 key_system_previous[q] = key_system[q];
9797 157959144 }
9798 7521864 }
9799
9800 8639330 void update_keys()
9801 {
9802
2/2
✓ Branch 0 taken 1097194910 times.
✓ Branch 1 taken 8639330 times.
1105834240 for (int32_t q = 0; q < 127; ++q)
9803 {
9804 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9805
1/2
✓ Branch 0 taken 1097194910 times.
✗ Branch 1 not taken.
1097194910 if (!replay_is_replaying())
9806 key_current_frame[q] = key[q];
9807
9808
2/2
✓ Branch 0 taken 1089125613 times.
✓ Branch 1 taken 8069297 times.
1097194910 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9809 1097194910 KeyInput[q] = key_current_frame[q];
9810 1097194910 key_previous_frame[q] = key_current_frame[q];
9811 1097194910 }
9812 8639330 }
9813
9814 bool zc_disablekey(int32_t k, bool val)
9815 {
9816 switch(k)
9817 {
9818 case KEY_F7:
9819 case KEY_F8:
9820 case KEY_F9:
9821 return false;
9822
9823 default:
9824 disabledKeys[k] = val;
9825 return true;
9826 }
9827 }
9828
9829 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9830 {
9831 timer=timer;
9832 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9833 }
9834
9835 // these are here so that copy_dialog won't choke when compiling zelda
9836 int32_t d_alltriggerbutton_proc(int32_t, DIALOG*, int32_t)
9837 {
9838 return D_O_K;
9839 }
9840
9841 int32_t d_comboa_radio_proc(int32_t, DIALOG*, int32_t)
9842 {
9843 return D_O_K;
9844 }
9845
9846 int32_t d_comboabutton_proc(int32_t, DIALOG*, int32_t)
9847 {
9848 return D_O_K;
9849 }
9850
9851 int32_t d_ssdn_btn_proc(int32_t, DIALOG*, int32_t)
9852 {
9853 return D_O_K;
9854 }
9855
9856 int32_t d_ssdn_btn2_proc(int32_t, DIALOG*, int32_t)
9857 {
9858 return D_O_K;
9859 }
9860
9861 int32_t d_ssdn_btn3_proc(int32_t, DIALOG*, int32_t)
9862 {
9863 return D_O_K;
9864 }
9865
9866 int32_t d_ssdn_btn4_proc(int32_t, DIALOG*, int32_t)
9867 {
9868 return D_O_K;
9869 }
9870
9871 int32_t d_sslt_btn_proc(int32_t, DIALOG*, int32_t)
9872 {
9873 return D_O_K;
9874 }
9875
9876 int32_t d_sslt_btn2_proc(int32_t, DIALOG*, int32_t)
9877 {
9878 return D_O_K;
9879 }
9880
9881 int32_t d_sslt_btn3_proc(int32_t, DIALOG*, int32_t)
9882 {
9883 return D_O_K;
9884 }
9885
9886 int32_t d_sslt_btn4_proc(int32_t, DIALOG*, int32_t)
9887 {
9888 return D_O_K;
9889 }
9890
9891 int32_t d_ssrt_btn_proc(int32_t, DIALOG*, int32_t)
9892 {
9893 return D_O_K;
9894 }
9895
9896 int32_t d_ssrt_btn2_proc(int32_t, DIALOG*, int32_t)
9897 {
9898 return D_O_K;
9899 }
9900
9901 int32_t d_ssrt_btn3_proc(int32_t, DIALOG*, int32_t)
9902 {
9903 return D_O_K;
9904 }
9905
9906 int32_t d_ssrt_btn4_proc(int32_t, DIALOG*, int32_t)
9907 {
9908 return D_O_K;
9909 }
9910
9911 int32_t d_ssup_btn_proc(int32_t, DIALOG*, int32_t)
9912 {
9913 return D_O_K;
9914 }
9915
9916 int32_t d_ssup_btn2_proc(int32_t, DIALOG*, int32_t)
9917 {
9918 return D_O_K;
9919 }
9920
9921 int32_t d_ssup_btn3_proc(int32_t, DIALOG*, int32_t)
9922 {
9923 return D_O_K;
9924 }
9925
9926 int32_t d_ssup_btn4_proc(int32_t, DIALOG*, int32_t)
9927 {
9928 return D_O_K;
9929 }
9930
9931 int32_t d_tri_edit_proc(int32_t, DIALOG*, int32_t)
9932 {
9933 return D_O_K;
9934 }
9935
9936 int32_t d_triggerbutton_proc(int32_t, DIALOG*, int32_t)
9937 {
9938 return D_O_K;
9939 }
9940
9941 /*** end of zc_sys.cc ***/
9942
9943